Created
January 18, 2017 10:32
-
-
Save leoiphonedev/30ddc4c3c9b37679dac8779039979072 to your computer and use it in GitHub Desktop.
Creating pageview showing 3 images and adding them to scroll view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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