Skip to content

Instantly share code, notes, and snippets.

@dlinsin
Created June 28, 2010 10:17
Show Gist options
  • Save dlinsin/455671 to your computer and use it in GitHub Desktop.
Save dlinsin/455671 to your computer and use it in GitHub Desktop.
@synthesize pageIndex = _pageIndex;
- (id) initWithParent:(UIView *)parent {
self = [super initWithParent:parent];
if (self == nil) {
return nil;
}
self.userInteractionEnabled = YES;
self.size = self.window.size;
[[UIImageView viewWithParent:self] setImageWithName:@"dailies"];
self.pageIndex = 0;
return self;
}
- (void)setPageIndex:(int)index {
if (index < 0 || index >= [self.subviews count]) {
return;
}
_pageIndex = index;
for (int i = 0; i < [self.subviews count]; i++) {
UIImageView *page = [self.subviews objectAtIndex:i];
page.x = (i < _pageIndex) ? -self.width : (i > _pageIndex) ? self.width : 0;
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
self.pageIndex++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment