zoukankan      html  css  js  c++  java
  • 根据屏幕分辨率判断当前手机型号(swift4.1)

    import UIKit
    
    class ViewController: UIViewController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
            // Do any additional setup after loading the view, typically from a nib.
            
            var label = "1"
            
            //获取屏幕大小
            let iOSDeviceScreenSize: CGSize = UIScreen.main.bounds.size
            
            NSLog("%@ x %@", iOSDeviceScreenSize.width, iOSDeviceScreenSize.height)
            var s : NSString = NSString(format: "%@ x %@",iOSDeviceScreenSize.width,iOSDeviceScreenSize.height)
            label = s as String
            
            
            //获取设备信息,判断是否为iphone
            if (UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.phone) {
    
                //判断是否为竖屏
                if (iOSDeviceScreenSize.height > iOSDeviceScreenSize.width){
                    if(iOSDeviceScreenSize.height == 568){
                        NSLog("iphone5/5s/5c/se")
                    } else if (iOSDeviceScreenSize.height == 667){
                        NSLog("iphone 6/6s/7/8")
                    } else if (iOSDeviceScreenSize.height == 736){
                        NSLog("iphone 6plus/6Splus/7plus/8plus ")
                    } else if (iOSDeviceScreenSize.height == 812){
                        NSLog("iphone X/XS ")
                    } else if (iOSDeviceScreenSize.height == 896){
                        NSLog("iphone XR/XSMax ")
                    } else {
                        NSLog("iphone4s....")
                    }
                }
                
                if (iOSDeviceScreenSize.width > iOSDeviceScreenSize.height){
                    if(iOSDeviceScreenSize.width == 568){
                        NSLog("iphone5/5s/5c/se")
                    } else if (iOSDeviceScreenSize.width == 667){
                        NSLog("iphone 6/6s/7/8")
                    } else if (iOSDeviceScreenSize.width == 736){
                        NSLog("iphone 6plus/6Splus/7plus/8plus ")
                    } else if (iOSDeviceScreenSize.width == 812){
                        NSLog("iphone X/XS ")
                    } else if (iOSDeviceScreenSize.width == 896){
                        NSLog("iphone XR/XSMax ")
                    } else {
                        NSLog("iphone4s....")
                    }
                }
                
            }
            
            
            
            
        }
    
    
    }
    
  • 相关阅读:
    一类分治问题
    [POI2005]DWU-Double-row
    [SCOI2007]降雨量
    [POI2007]ODW-Weights(贪心)
    bzoj3427小P的牧场(斜率优化dp)
    UVA10559 Blocks(区间dp)
    LOJ6089 小Y的背包计数问题(根号优化背包)
    [APIO2008]免费道路(生成树)
    bzoj4383(拓扑排序)
    [HEOI2014]平衡(整数划分数)
  • 原文地址:https://www.cnblogs.com/nolang/p/11412058.html
Copyright © 2011-2022 走看看