`

UIScrollView

 
阅读更多
- (void)viewDidLoad
{
    [super viewDidLoad];
     
    scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
    scrollView.backgroundColor = [UIColor redColor];
    // 是否支持滑动最顶端
//    scrollView.scrollsToTop = NO;
    scrollView.delegate = self;
    // 设置内容大小
    scrollView.contentSize = CGSizeMake(320, 460*10);
    // 是否反弹
//    scrollView.bounces = NO;
    // 是否分页
//    scrollView.pagingEnabled = YES;
    // 是否滚动
//    scrollView.scrollEnabled = NO;
//    scrollView.showsHorizontalScrollIndicator = NO;
    // 设置indicator风格
//    scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
    // 设置内容的边缘和Indicators边缘
//    scrollView.contentInset = UIEdgeInsetsMake(0, 50, 50, 0);
//    scrollView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 50, 0, 0);
    // 提示用户,Indicators flash
    [scrollView flashScrollIndicators];
    // 是否同时运动,lock
    scrollView.directionalLockEnabled = YES;
    [self.view addSubview:scrollView];
     
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 200, 320, 40)];
    label.backgroundColor = [UIColor yellowColor];
    label.text = @"学习scrolleview";
    [scrollView addSubview:label];
    [label release];
}

 UIScrollView基本用法

  • 大小: 94.7 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics