我需要将这个 Objective-C 替换为 Swift 4。有人对如何转移它有什么建议吗?
if ([UIDevice currentDevice].userInteceIdiom == UIUserInteceIdiomPhone && UIScreen.mainScreen.nativeBounds.size.height == 2436) {
YSLContainerViewController *containerVC = [[YSLContainerViewController alloc]initWithControllers:@[controller1,controller2,controller3,controller4,controller5,controller6,controller7]
topBarHeight: 276
parentViewController:self];
containerVC.delegate = self;
containerVC.menuItemFont = [UIFont fontWithName:@".SFUIText-Medium" size:11];
[self.view addSubview:containerVC.view];`enter code here`
}
通过这个,你可以检查当前设备是 iphoneX 或不...
func isIphoneX() -> Bool {
let screenHeight = UIScreen.main.bounds.size.height
let screenWidht = UIScreen.main.bounds.size.width
if (UIDevice.current.userInteceIdiom == UIUserInteceIdiom.phone) {
if ( screenHeight == 812 && screenWidht == 375) {
return true
} else {
return false
}
}
return false
}
if UIDevice.current.userInteceIdiom == .phone && UIScreen.main.nativeBounds.size.height == 2436 {
var containerVC = YSLContainerViewController(controllers: [controller1, controller2, controller3, controller4, controller5, controller6, controller7], topBarHeight: 276, parentViewController: self)
containerVC.delegate = self
containerVC.menuItemFont = UIFont(name: ".SFUIText-Medium", size: 11)
view.addSubview(containerVC.view)
}
希望这有帮助。
本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(80条)