This is my understanding about UIScrollView (iOS 7):
contentOffset
defines the point of origin of the content viewcontentInset
effectively can add "padding" around the content view
In Xcode, I created a single-view application. In IB, I added a UIScrollView
to the view controller, and embedded the controller in a navigation controller. In the view controller code, I added the following method:
- (void)viewDidAppear:(BOOL)animated
{
[self.scrollView setContentSize:CGSizeMake(380, 1000)];
NSLog(@"top = %f, bounds top %f", self.scrollView.frame.origin.y, self.scrollView.bounds.origin.y);
NSLog(@"offset y = %f", self.scrollView.contentOffset.y);
NSLog(@"height = %f", self.scrollView.contentSize.height);
NSLog(@"inset top = %f", self.scrollView.contentInset.top);
NSLog(@"inset bottom = %f", self.scrollView.contentInset.bottom);
}
My results:
top = 0.000000, bounds top -64.000000
offset y = -64.000000
height = 1000.000000
top = 64.000000
bottom = 0.000000
The contentInset.top
value effectively moves the content down so it is below the navigation bar. Why is contentOffset.y
being set to -64, and the bounds of the scroll view being set to -64?
Thanks in advance