Determine device (iPhone, iPod Touch) with iOS

后端 未结 30 1812
礼貌的吻别
礼貌的吻别 2020-11-21 11:29

Is there a way to determine the device running an application. I want to distinguish between iPhone and iPod Touch, if possible.

30条回答
  •  猫巷女王i
    2020-11-21 12:06

    To identifiy iPhone 4S, simply check the following:

    var isIphone4S: Bool {
    
        let width = UIScreen.main.bounds.size.width
        let height = UIScreen.main.bounds.size.height
        let proportions = width > height ? width / height : height / width
    
        return proportions == 1.5 && UIDevice.current.model == "iPhone"
    }
    

提交回复
热议问题