美文网首页
iOS-userInterfaceIdiom-判断当前设备

iOS-userInterfaceIdiom-判断当前设备

作者: iOS苦逼开发 | 来源:发表于2017-06-05 17:29 被阅读193次

通过UIDevice().userInterfaceIdiom来判断是iPhone或者iPad,以此来执行不同的操作,或者为控件制定不同的frame

image.png
if UIDevice().userInterfaceIdiom == .Phone {
            switch UIScreen.mainScreen().nativeBounds.height {
            case 960:
                productTitle.frame = CGRect(x: 7, y: 125, width:cell.frame.size.width-14, height: 23)
            case 1136:
                productTitle.frame = CGRect(x: 7, y: 125, width:cell.frame.size.width-14, height: 23)
            default:
                productTitle.frame = CGRect(x: 7, y: 178, width:cell.frame.size.width-14, height: 23)
            }
        }  

相关文章

网友评论

      本文标题:iOS-userInterfaceIdiom-判断当前设备

      本文链接:https://www.haomeiwen.com/subject/tffwfxtx.html