Skip to content

Instantly share code, notes, and snippets.

@leoiphonedev
Created January 18, 2017 10:32
Show Gist options
  • Save leoiphonedev/30ddc4c3c9b37679dac8779039979072 to your computer and use it in GitHub Desktop.
Save leoiphonedev/30ddc4c3c9b37679dac8779039979072 to your computer and use it in GitHub Desktop.
Creating pageview showing 3 images and adding them to scroll view
#define SCROLLWIDTH 279
- (void)viewDidLoad {
scrollView.contentSize=CGSizeMake(SCROLLWIDTH*3,
scrollView.frame.size.height);
scrollView.delegate = self;
for (int i =0; i<=3; i++) {
UIImageView *imageView = [[UIImageView alloc]initWithFrame:
CGRectMake(SCROLLWIDTH*i, 0, scrollView.frame.size.width,
scrollView.frame.size.height)];
if (i==0) {
imageView.backgroundColor = [UIColor redColor];
}
else if (i==1) {
imageView.backgroundColor = [UIColor greenColor];
}
else {
imageView.backgroundColor = [UIColor yellowColor];
}
[scrollView addSubview:imageView];
}
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment