标签:
@implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; //创建一个scrollview UIScrollView *_scrollview = [[UIScrollView alloc]init]; _scrollview.frame = CGRectMake(10,20,200,300); _scrollview.backgroundColor = [UIColor grayColor]; [self.view addSubview:_scrollview]; UIImageView *bgimage = [[UIImageView alloc]init]; bgimage.image = [UIImage imageNamed:@"guide.png"]; CGFloat height = bgimage.image.size.height; CGFloat width = bgimage.image.size.width; bgimage.frame = CGRectMake(0, 0, width, height); [_scrollview addSubview:bgimage]; //scrollview滑动的范围,加上此句后出现水平及纵向拖动条 _scrollview.contentSize = bgimage.image.size; //拖动到结束时增加弹簧效果 _scrollview.bounces = TRUE; //水平拖动条显示 _scrollview.showsHorizontalScrollIndicator = YES; //垂直拖动条显示 _scrollview.showsVerticalScrollIndicator = YES; //拖动条的风格 // UIScrollViewIndicatorStyleDefault, 默认风格 // UIScrollViewIndicatorStyleBlack, 黑色风格 // UIScrollViewIndicatorStyleWhite 白色风格 _scrollview.indicatorStyle = UIScrollViewIndicatorStyleWhite; _scrollview.pagingEnabled = YES; } @end
标签:
原文地址:http://www.cnblogs.com/Fredric-2013/p/5205307.html