UIScrollView
contentSize //定义内容区域大小,决定是否能够滚动
contentOffset //屏幕左上角距离坐标原点的偏移量
scrollsToTop //滑动到顶部(点状态的时候)
pagingEnabled //是否整屏翻动
bounces //边界是否回弹
//1.创建一个scroll对象
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 100, WHIDTH , HEIGTH-300)];
//2.设置画卷大小
scroll.contentSize = CGSizeMake(375*11, 30);//设置画卷大小,如果左右滑动宽必须大于屏幕的宽,上下滑动高必须大于屏的高度
//3.设置画卷属性
scroll.pagingEnabled = YES;//设置整页滑动
scroll.scrollEnabled = YES;//是否允许滑动
scroll.backgroundColor = [UIColor whiteColor];//设置画卷背景色
scroll.bounces = YES;//设置回弹效果
//scroll.contentOffset = CGPointMake(200, 40);//设置画卷的初始位置
scroll.showsHorizontalScrollIndicator = YES;//是否显示水平滚动条
scroll.showsVerticalScrollIndicator = NO;//是否显示垂直滚动条
scroll.scrollsToTop = YES;//点击状态栏时,是否允许画卷滚动到顶部
scroll.delegate = self;//设置代理
// scroll.zooming = YES;//是否允许缩放为只读装填
// scroll.zoomScale = 2;//
[self.view addSubview: scroll];
//添加图片
for(int i=0;i<11;i++)
{
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(WHIDTH*i, 0, WHIDTH,375)];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg",i+1]];
imageView.contentMode = UIViewContentModeScaleAspectFit;
[scroll addSubview:imageView];
}
page = [[UIPageControlalloc] initWithFrame:CGRectMake(87, 500, 200, 40)];
page.numberOfPages = 11;//设置页数
page.currentPage = 0;//设置当前页
page.currentPageIndicatorTintColor = [UIColorredColor];//设置点的颜色
page.defersCurrentPageDisplay =NO;//手动移动页码
page.pageIndicatorTintColor = [UIColorblackColor];//设置非点的颜色
// page.backgroundColor = [UIColor grayColor];
[self.view addSubview:page];
// Do any additional setup after loading the view, typically from a nib.
}//事件处理
-(void)scrollViewDidScroll:(UIScrollView *)scrollView//
{
page.currentPage = scrollView.contentOffset.x/375;
}