Reputation: 5928
How do I pin a view's bottom anchor to it's superview's bottom safe area anchor in iOS 11 using interface builder?
I have been able to do it programmatically like so:
if (@available(iOS 11.0, *)) {
[self.myBottomView.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor].active = true;
} else {
[self.myBottomView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor].active = true;
}
When I go to interface builder I cannot see the bottom safe area anchor:
Upvotes: 1
Views: 2684
Reputation: 1625
On a project created before Xcode 9, storyboards and xibs are not updated automatically to use the safe areas because the existing constraints needs to be changed manually.
You can enable this with an option in the file inspector (in the right panel):
Then, the safe area appears like a specific kind a view and you can use it to add your constraints:
Note that it is possible to use the safe area in a storyboard and have a deployment target lower than iOS 11. I tested in the simulator with iOS 10 and it works as expected.
Upvotes: 4