码迷,mamicode.com
首页 > 其他好文 > 详细

UI控件(UIScrollView)

时间:2016-02-21 18:30:32      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

@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)

标签:

原文地址:http://www.cnblogs.com/Fredric-2013/p/5205307.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!