Remove unwanted ios7 padding

2019-06-27 13:10发布

问题:

iOS7 adds padding (64px) for the status bar. Therefore when using a Scrollview there is a big camp between the scrollview and the navigation bar. I tried:

self.automaticallyAdjustsScrollViewInsets = NO;

Which does remove the unwanted padding - however the scrollview no longer scrolls.

Is there another way?

* update **

I discovered a quick fix. I was lining up the scrollview and y origin= 64px in the storyboard instead of 0. I put my scroll view to 0px (the navigation bar then covered 64px of my scrollview) and when I ran it on the simulator it was aligned as originally intend ... a bit of a hack tho. I'm looking for a solid solution however.

回答1:

On your XIB/Storyboard for your view controller, make sure to uncheck the Adjust Scroll View Insets. You may also need to uncheck Under Top Bars and Under Bottom Bars: