设为首页 加入收藏

TOP

【代码笔记】iOS-两个滚动条,上下都能滑动(二)
2017-10-13 10:33:05 】 浏览:9129
Tags:代码 笔记 iOS- 两个 滚动 上下 都能 滑动
imageViewBook.tag = i; UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doClickTapGesture:)]; [imageViewBook addGestureRecognizer:tapGesture]; [scrollerViewFirst addSubview:imageViewBook]; } //scrollerSecond的标题 for (int i = 0; i < 4; i++) { UIImageView *topImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"scrollerSecondTop"]]; topImageView.frame = CGRectMake(100 + 320 *i , -40 , 220, 100); [scrollerViewSecond addSubview:topImageView]; UIImageView *titleImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"scrollerSecondTitle.png"]]; titleImageView.frame = CGRectMake(3 + 320 *i, 20, 100, 55); [scrollerViewSecond addSubview:titleImageView]; } //scrollerViewSecond每个里面的线 for (int i = 0; i < 4;i++) { for ( int j = 0; j < 3; j++) { label = [[UILabel alloc]initWithFrame:CGRectMake(320*i , 80 + 60 *j, 320, 20)]; if (i==0) { label.backgroundColor=[UIColor redColor]; }else if (i==1){ label.backgroundColor=[UIColor greenColor]; }else if (i==2){ label.backgroundColor=[UIColor blackColor]; }else if (i==3){ label.backgroundColor=[UIColor blueColor]; } [label setFont:[UIFont systemFontOfSize:12]]; label.textAlignment = NSTextAlignmentCenter; label.textColor = [UIColor blueColor]; [scrollerViewSecond addSubview:label]; } } } #pragma -mark -doClickAction -(void)doClickTapGesture:(UITapGestureRecognizer *)tapGesture { NSLog(@"doClickTapGesture"); //一个页面从右侧翻转过来的效果 [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.7]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES]; [self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:0]; [UIView commitAnimations]; bigImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"%ld.png",tapGesture.view.tag +1]]]; bigImageView.frame = CGRectMake(0,0,300, 440); bigImageView.userInteractionEnabled = YES; UITapGestureRecognizer * tgrBig = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(beginSmall:)]; [bigImageView addGestureRecognizer:tgrBig]; bigView.alpha = 0.2; UIScrollView *scrollerViewThree = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 300, 440 )]; scrollerViewThree.delegate = self; scrollerViewThree.maximumZoomScale = 3.0; scrollerViewThree.minimumZoomScale = 1; [bigView addSubview: scrollerViewThree]; [scrollerViewThree addSubview:bigImageView]; } -(void)beginSmall:(UIGestureRecognizer *)sender { NSLog(@"--doClickbeginSmall--"); [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.7]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES]; [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1]; [UIView commitAnimations]; bigView.alpha = 1; [bigImageView removeFromSuperview]; }
复制代码

 

 

 
 
首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇【Swift学习】Swift编程之旅---扩.. 下一篇UITableView点击每个Cell,Cell的..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目