When you open the view, it will look like the image below,
For iphone x, I would like to add a safe area programmatically in the current view.
The source to try is as follows.
UIView *view = self.view;
if (@available(iOS 11.0, *)) {
UILayoutGuide * guide = view.safeAreaLayoutGuide;
[view.topAnchor constraintEqualToAnchor:guide.topAnchor].active = YES;
[view.bottomAnchor constraintEqualToAnchor:guide.bottomAnchor].active = YES;
}
I suppose to apply this source, but I do not know what to do.
please answer about my question.!
Here is sample code for Safe Area Layout. Try this in Objective-C and see:
Ref from: Use Safe Area Layout programmatically
Result: