此行代码将转换为iPhone X的安全区域
self.view.translatesAutoresizingMaskIntoConstraints = NO;
id views = @{
@"carbonTabSwipe" : self.view,
@"topLayoutGuide" : rootViewController.topLayoutGuide,
@"bottomLayoutGuide" : rootViewController.bottomLayoutGuide
};
NSString *verticalFormat = @"V:[topLayoutGuide][carbonTabSwipe][bottomLayoutGuide]";
[rootViewController.view
addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:verticalFormat
options:0
metrics:nil
views:views]];
[rootViewController.view
addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[carbonTabSwipe]|"
options:0
metrics:nil
views:views]];
这适用于其他设备,但iPhone X的底部显示空格。