UIPageControl
2015-09-15 20:08
483 查看
self.pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 0, 275, 30)]; _pageControl.center = CGPointMake(375 / 2, 667 - 100); self.view.backgroundColor = [UIColor whiteColor]; //设置当前点的颜色 _pageControl.currentPageIndicatorTintColor = [UIColor purpleColor]; //设置其他点颜色 _pageControl.pageIndicatorTintColor = [UIColor lightGrayColor]; //设置点的个数 _pageControl.numberOfPages = 6; //设置当前点的位置 _pageControl.currentPage = 0; //添加事件 [_pageControl addTarget:self action:@selector(pageControlAction:) forControlEvents:UIControlEventValueChanged]; #pragma mark - 点击事件 -(void)pageControlAction:(UIPageControl *)pageControl { NSLog(@"%ld",pageControl.currentPage); //设置scrollView的偏移量 _scrollView.contentOffset = CGPointMake(375 * pageControl.currentPage, 0); } -(void)tapAction:(UITapGestureRecognizer *)tap { UIAlertView *alerView = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"欢迎使用" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确认", nil]; [alerView show]; [alerView release]; [self.scrollView removeFromSuperview]; [self.pageControl removeFromSuperview]; } //将要减速 -(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView { _pageControl.currentPage = scrollView.contentOffset.x / 375; } //停止 -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { _pageControl.currentPage = scrollView.contentOffset.x / 375; }
相关文章推荐
- UI_UITableView _新知识_02
- HDU 1423 Greatest Common Increasing Subsequence
- UIScrollView
- android之视频的播放(VedioView,SuefaceView)和图片的获得
- 10810 - Ultra-QuickSort(求逆序数)
- UISlider
- .net micro framework Netduino无法休眠
- UE4材质初探
- UE4 Material - How To Use Fresnel in your Materials
- UI课程07 UIScrollView、UIPageControl
- uva 1584 Circular Sequence (字符串处理)
- 记录一些UIScrollView的使用方法
- java 之DelayQueue实际运用示例
- UISegmentedControl
- UIImageView
- UITableView 常用方法列表
- UIButton 方法以及属性
- NGUI
- UIImageview 模糊、高斯模糊
- NGUI使用图片制作文字