@interface ViewController ()
{
    UIScrollView *_scrollView;

}

@end
- (void)viewDidLoad
{    
    [super viewDidLoad];
    
    _scrollView = [[UIScrollView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    
    _scrollView.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:_scrollView];
//水平三个
        UIView *v1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _scrollView.frame.size.width, _scrollView.frame.size.height)];
    v1.backgroundColor = [UIColor redColor];
    [_scrollView addSubview:v1];
    
    
    UIView *v2 = [[UIView alloc] initWithFrame:CGRectMake(0, _scrollView.frame.size.height, _scrollView.frame.size.width, _scrollView.frame.size.height)];
    v2.backgroundColor = [UIColor yellowColor];
    [_scrollView addSubview:v2];
    
    
    UIView *v3 = [[UIView alloc] initWithFrame:CGRectMake(0, _scrollView.frame.size.height * 2, _scrollView.frame.size.width, _scrollView.frame.size.height)];
    v3.backgroundColor = [UIColor blueColor];
    [_scrollView addSubview:v3];
    //横着的
    UIView *v4 = [[UIView alloc] initWithFrame:CGRectMake(_scrollView.frame.size.width, 0, _scrollView.frame.size.width, _scrollView.frame.size.height)];
    
    v4.backgroundColor = [UIColor orangeColor];
    [_scrollView addSubview:v4];
    
    
    UIView *v5 = [[UIView alloc] initWithFrame:CGRectMake(_scrollView.frame.size.width * 2, 0, _scrollView.frame.size.width, _scrollView.frame.size.height)];
    
    v5.backgroundColor = [UIColor brownColor];
    [_scrollView addSubview:v5];
    
    
    _scrollView.contentSize = CGSizeMake(_scrollView.frame.size.width * 3,_scrollView.frame.size.height * 3);
    
    _scrollView.pagingEnabled = YES;
}

 

posted on 2016-01-07 13:54  良小辰  阅读(642)  评论(0编辑  收藏  举报