标签:
//滚动视图 经常用来显示一屏不能够显示完全的内容
UIScrollView *sv = [[UIScrollView alloc] init];
//设置滚动视图的显示大小
sv.frame = CGRectMake(30, 40, 250, 320);
//设置滚动视图内容的大小
sv.contentSize = CGSizeMake(250 * 15, 320 * 2);
sv.backgroundColor = [UIColor lightGrayColor];
//设置滚动视图的弹动效果,默认为YES
sv.bounces = YES;
//设置显示水平滚动指示条是否显示,默认为YES
sv.showsHorizontalScrollIndicator = YES;
//设置垂直滚动指示条是否显示,默认为YES
sv.showsVerticalScrollIndicator = YES;
//设置水平弹动效果,默认为NO
sv.alwaysBounceHorizontal = NO;
//设置垂直的弹动效果,默认为NO
sv.alwaysBounceVertical = YES;
//是否按页显示内容,YES,每次移动翻一页, NO,每次移动翻多页
sv.pagingEnabled = YES;
//设置滚动视图当前的显示位置
sv.contentOffset = CGPointMake(250 * 2, 0);
[self.view addSubview:sv];
for (int i = 0; i < 15; i++) {
UIImageView *imageView = [[UIImageView alloc] init];
imageView.frame = CGRectMake(0 + i * 250, 0, 250, 320);
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"17_%d.jpg", i + 1]];
//将要显示的内容添加到滚动视图上
[sv addSubview:imageView];
}
标签:
原文地址:http://www.cnblogs.com/zym888/p/4575080.html