Implementing UIScrollView programmatically

前端 未结 3 1712
执笔经年
执笔经年 2020-12-18 10:02

In the page control sample from apple there is a ScrollView in the interface builder. It is linked with the corresponding IBOutlet. I want to change the code so this is all

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-18 10:15

    Simple Method: You can created multiple times if you need means

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        int x = 0;
        int y = 10;
        for(int i=0; i<5; i++)
        {
            UIScrollView *scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(x, y, 50, 50)];
            scrollview.showsVerticalScrollIndicator=YES;
            scrollview.scrollEnabled=YES;
            scrollview.userInteractionEnabled=YES;
            scrollview.backgroundColor = [UIColor greenColor];
            [self.view addSubview:scrollview];
            //scrollview.contentSize = CGSizeMake(50,50);
            x=x+55;
    
            //[self myscrollView];
        }
    }
    

提交回复
热议问题