UIScrollView
1.滚动范围 contentSize CGSizeMake(WIDTH * 6, HEIGHT)
2.按页来进行滚动 pagingEnabled YES
3.偏移量 contentOffset CGPointMake(WIDTH * 2, 0)
4.边界回弹 bounces NO
5.滚动条显示或隐藏 showsHorizontalScrollIndicator NO // 水平
showsVerticalScrollIndicator NO // 垂直
6.整页翻动 (以当前滚动视图的宽度为1页) pagingEnabled YES
7.滚到顶部 (每个滚动视图默认都为YES 一个页面中存在多个滚动视图时 仅开启需要滚动的视图 其它滚动视图设置为NO)
scrollsToTop YES
8.是否允许滚动 scrollEnabled YES
9.创建UIScrollView
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
scrollView.backgroundColor = [UIColor yellowColor];
[self.view addSubview:scrollView];
[scrollView release];
//只要滚动就会触发的协议方法
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
NSLog(@"开始滚动");
}
//当scrollView减速停止的时候会触发的协议方法
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
NSLog(@"滚动停止");
if (scrollView.contentOffset.x == WIDTH * 5) {
scrollView.contentOffset = CGPointMake(WIDTH * 1, 0);
}
if (scrollView.contentOffset.x == 0) {
scrollView.contentOffset = CGPointMake(WIDTH * 4, 0);
}
}