Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // BEGIN ScrollView Test
- UIScrollView *MyScrollViewObj = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 112.0, 342.0, 50.0)];
- // Adjust the width to be larger to make it scroll horizontal
- // Adjust the height to be larger to be scrolled vertical
- [MyScrollViewObj setContentSize:CGSizeMake(3420.0, 20.0)];
- [MyScrollViewObj setScrollEnabled:YES];
- [MyScrollViewObj setPagingEnabled:YES];
- [MyScrollViewObj setShowsHorizontalScrollIndicator:NO];
- [MyScrollViewObj setShowsVerticalScrollIndicator:NO];
- // Add objects to scroll view
- CGFloat y = 0;
- for (NSInteger i = 0; i < 20; i++) {
- UILabel *l = [[UILabel alloc] initWithFrame:CGRectMake(y, 0, 150.0, 20.0)];
- NSString *text = [NSString stringWithFormat:@"Label %d", i];
- NSLog(@"Creating label with text: %@", text);
- [l setText:text];
- [MyScrollViewObj addSubview:l];
- [l release];
- y = y + 160;
- }
- // Add scroll to window
- [window addSubview:MyScrollViewObj];
- [MyScrollViewObj release];
- // END ScrollView Test
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement