Adjust settings view for iPhone X

This commit is contained in:
Cameron Gutman
2017-09-14 23:12:52 -07:00
parent da1115e529
commit 86f7112789

View File

@@ -14,9 +14,30 @@
@implementation SettingsViewController {
NSInteger _bitrate;
Boolean _adjustedForSafeArea;
}
static NSString* bitrateFormat = @"Bitrate: %.1f Mbps";
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// Adjust the subviews for the safe area on the iPhone X.
if (!_adjustedForSafeArea) {
if (@available(iOS 11.0, *)) {
for (UIView* view in self.view.subviews) {
// HACK: The official safe area is much too large for our purposes
// so we'll just use the presence of any safe area to indicate we should
// pad by 20.
if (self.view.safeAreaInsets.left >= 20 || self.view.safeAreaInsets.right >= 20) {
view.frame = CGRectMake(view.frame.origin.x + 20, view.frame.origin.y, view.frame.size.width, view.frame.size.height);
}
}
}
_adjustedForSafeArea = true;
}
}
- (void)viewDidLoad {
[super viewDidLoad];