Infinite Scrolling in UIScrollView

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [theScrollView setContentSize:CGSizeMake(3 * theScrollView.bounds.size.width, theScrollView.bounds.size.height)];
    [theScrollView setPagingEnabled:YES];
    
    CGRect aFrame = theScrollView.bounds;
    
    UIView* view;
    NSLog(@"Frame: %@", NSStringFromCGRect(aFrame));
    view = [[UIView alloc] initWithFrame:aFrame];
    [view setBackgroundColor:[UIColor blueColor]];
    [theScrollView addSubview:view];
    
    aFrame = CGRectOffset(aFrame, theScrollView.bounds.size.width, 0);
    NSLog(@"Frame: %@", NSStringFromCGRect(aFrame));
    view = [[UIView alloc] initWithFrame:aFrame];
    [view setBackgroundColor:[UIColor redColor]];
    [theScrollView addSubview:view];
        
    aFrame = CGRectOffset(aFrame, theScrollView.bounds.size.width, 0);
    NSLog(@"Frame: %@", NSStringFromCGRect(aFrame));
    view = [[UIView alloc] initWithFrame:aFrame];
    [view setBackgroundColor:[UIColor yellowColor]];
    [theScrollView addSubview:view];
    
    
}
原文地址:https://www.cnblogs.com/neozhu/p/2552039.html