Reputation: 1550
In my swift 4
project I have iOS 9.0
as deployement target
and I'm using the safe area layout guide
.
In the storyboard
, I always give 0 as value between my main view
top space and the safe area
top. When I run the application in iOS 9
or iOS 10
I'm having a white space at the top.
How can I remove this white space without disabling the safe area layout guide
?
Upvotes: 2
Views: 1870
Reputation: 1915
I can't explain why, but in the storyboard views don't calculate the navigationbar height and therefor you will have an (often 44px) white space. You can remove this by either as Lazy said, by turning of Adjust Scroll View insets
or you can do it programmatically by setting edgesForExtendedLayout = []
in your viewDidLoad()
https://developer.apple.com/documentation/uikit/uiviewcontroller/1621515-edgesforextendedlayout tells you some more about it.
Upvotes: 0
Reputation: 680
Goto Storyboard
> Select the ViewController
> Attribute Inspector
(3rd Tab from right in the right pane.) > Uncheck Adjust Scroll View insets
.
Upvotes: 3
Reputation: 4817
I guess you are testing on iPhone X? You can change safe area insets such way:
var newSafeArea = UIEdgeInsets()
newSafeArea.top -= 20
self.additionalSafeAreaInsets = newSafeArea
Upvotes: 1