UI控件(UIScrollView)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UI控件(UIScrollView)相关的知识,希望对你有一定的参考价值。
@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
以上是关于UI控件(UIScrollView)的主要内容,如果未能解决你的问题,请参考以下文章
iOS开发UI篇—UIScrollView控件实现图片缩放功能