1.UIScrollew
1》常见属性
UIScrollew不能滚动时查看这几个属性设置了没: contentSize ;scrollEnabled;
contentSize : UIScrollew能滚动到实际尺寸。 (必须设置)
contentOffset :偏移量 (CGPoint类型) (可以获取 或者 手动进行设置)
[ScrollView setContentOffset:CGPointMake(0, 0) animated:YES]; 使用set方法可以有donghua
pagingEnabled = yes : 分页效果,根据UIScrollew的宽度进行分页
scrollEnabled : 是否允许滚动
contentInset : 内边距
bounces : 是否需要弹簧效果
showsHorizontalScrollIndicator = no :水平滚动条隐藏
showsVerticalScrollIndicator = no : 垂直滚动条隐藏
2.监听 UIScrollew 的滚动,使用代理 可以时时监控滚动到什么位置
代理方法:
1》 - (void)scrollViewDidScroll:(UIScrollView *)scrollView; //用户在滚动的时候
2》- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView; //用户拖拽完毕以后
3》 - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView; // 用户即将脱拽的时候
minimumZoomScale :最小的缩放多小
maximumZoomScale : 最大放多大
4》- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView; // 缩放
2.UIPageControll
常用属性
numberOfPages :总页数
currentPage : 指定默认第几页
pageIndicatorTintColor : 颜色
currentPageIndicatorTintColor :当前指示器颜色
//轮播图:在UIScrollew 的滚动代理方法中 计算试图的偏移量:加上半页的宽度,用偏移量/页的宽度,得到当前指示器位置。
3.NSTimer
1>创建
创建好后自动启动
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(nstimer) userInfo:nil repeats:YES];
// 在计时器的方法中,拿到当前页码数,判断是不是最后一页,如果是等于第一页,页吗++,偏移量等于宽度 * 页吗。
//注意:在即将实施拖拽时,停止计时器 [timer invalidate] ,将计时器指向 nil , 在拖拽完毕时,重新开启一个计时器。
//需要提高时间控制器的优先级 , 对拖拽完毕重新创建的nstimer 也需要提升优先级
NSRunLoop *loop = [NSRunLoop currentRunLoop];
[loop addTimer:timer forMode:NSRunLoopCommonModes];