Created
January 13, 2013 18:42
-
-
Save mwhuss/4525626 to your computer and use it in GitHub Desktop.
Paging Scroll View
This file contains 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
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds))]; | |
scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | |
scrollView.pagingEnabled = YES; | |
[self.view addSubview:scrollView]; | |
NSArray *images = @[@"image1", @"image2", @"image3"]; | |
[images enumerateObjectsUsingBlock:^(NSString *imageName, NSUInteger idx, BOOL *stop) { | |
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]]; | |
imageView.frame = CGRectMake(idx * CGRectGetWidth(self.view.bounds), 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds)); | |
[self.scrollView addSubview:imageView]; | |
}]; | |
self.scrollView.contentSize = CGSizeMake([images count] * CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment