X 7 plus:如何在swift4中以编程方式检查iphone7plus和iphone x的屏幕尺寸

关于X 7 plus的问题,在size of iphone 7 plus screen中经常遇到, 我需要将这个 Objective-C 替换为 Swift 4。有人对如何转移它有什么建议吗?

我需要将这个 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`  
     }
1
Swift 4.0

通过这个,你可以检查当前设备是 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
        }
0
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)
}

希望这有帮助。

本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处

(141)
七日杀服务器搭建:必须做亚行杀服务器和启动服务器每次在Ubuntu中识别Android设备
上一篇
Dakota:构建 Dakota时配置错误
下一篇

相关推荐

发表评论

登录 后才能评论

评论列表(80条)