Created
September 11, 2012 17:24
-
-
Save samdmarshall/3700002 to your computer and use it in GitHub Desktop.
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
| - (id)initWithFrame:(CGRect)frame | |
| { | |
| self = [super initWithFrame:frame]; | |
| if (self) { | |
| // Initialization code | |
| self.pagingEnabled = YES; | |
| self.contentSize = CGSizeMake(frame.size.width * 3, frame.size.height); | |
| NSArray *master_color = @[[UIColor yellowColor], [UIColor magentaColor], [UIColor cyanColor]]; | |
| for (int i = 0; i < 3; i++) { | |
| UIView *master_backing = [[UIView alloc] initWithFrame:CGRectMake(frame.size.width*i, 0, frame.size.width, frame.size.height)]; | |
| master_backing.backgroundColor = [master_color objectAtIndex:i]; | |
| UILabel *master_page_label = [[UILabel alloc] initWithFrame:CGRectMake(0, frame.size.height-50, frame.size.width, 50)]; | |
| master_page_label.text = [NSString stringWithFormat:@"Article %i", i]; | |
| master_page_label.backgroundColor = [UIColor clearColor]; | |
| [master_backing addSubview:master_page_label]; | |
| [self addSubview:master_backing]; | |
| CGRect current_page = CGRectMake(frame.size.width*i, 0, frame.size.width, frame.size.height); | |
| UIScrollView *test = [[UIScrollView alloc] initWithFrame:current_page]; | |
| test.contentSize = CGSizeMake(frame.size.width * 3, frame.size.height); | |
| test.pagingEnabled = YES; | |
| NSArray *page_color = @[[UIColor redColor], [UIColor blueColor], [UIColor greenColor]]; | |
| for (int j = 0; j < 3; j++) { | |
| UIView *page = [[UIView alloc] initWithFrame:CGRectMake(frame.size.width*j, 0, frame.size.width, frame.size.height)]; | |
| page.backgroundColor = [page_color objectAtIndex:j]; | |
| UILabel *sub_page_label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)]; | |
| sub_page_label.text = [NSString stringWithFormat:@"Page %i",j]; | |
| sub_page_label.backgroundColor = [UIColor clearColor]; | |
| [page addSubview:sub_page_label]; | |
| [test addSubview:page]; | |
| } | |
| [self addSubview:test]; | |
| } | |
| } | |
| return self; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment