1. 程式人生 > >IOS UIScrollView背景色 及滑動範圍設定

IOS UIScrollView背景色 及滑動範圍設定

#import "ViewController.h"



@interface ViewController ()

@end


@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

//    _scrollview1.backgroundColor = [UIColor greenColor]; //設定背景色
//    _scrollview2.backgroundColor = [UIColor yellowColor];
    _scrollview1.frame = CGRectMake(0, 0, 80, 1000);//固定位置及大小
    _scrollview2.frame = CGRectMake(80, 20, 240, 550);
//    NSLog(@"%f,%f",_scrollview1.frame.origin.x, _scrollview1.frame.origin.y);//輸出座標
//    NSLog(@"%f,%f",_scrollview2.frame.origin.x, _scrollview2.frame.origin.y);
    // Do any additional setup after loading the view, typically from a nib.
}

-(void) viewDidAppear:(BOOL)animated
{
    _scrollview1.contentSize = CGSizeMake(80, 900);//確定滑動範圍 超出才會有滑動效果
    _scrollview2.contentSize = CGSizeMake(240, 900);
    
}