iOS-userInterfaceIdiom-判断当前设备

2017-06-05  本文已影响193人  iOS苦逼开发

通过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)
            }
        }  
上一篇 下一篇

猜你喜欢

热点阅读