概述
获取设备的信息,比如系统版本号、屏幕高宽等。在IOS中,我们通过访问UIDevice类,获取设备信息;通过UIScreen获取屏幕的信息。
SCDevice
1import Foundation 2import UIKit 3 4public class SCDevice{ 5 6 /** 7 获取设备的版本号 8 9 :returns: 设备版本号,Double类型 10 */ 11 public class func getVersion()->Double{ 12 13 return (UIDevice.currentDevice().systemVersion as NSString).doubleValue 14 15 } 16 17 18 /** 19 获取设备的西系统名称 20 21 :returns: 设备的系统名称,String类型 22 */ 23 public class func getSystemName()->String{ 24 25 return UIDevice.currentDevice().systemName 26 } 27 28 /** 29 获取屏幕的宽和高 30 31 :returns: 返回元组类型,包含宽和高 32 */ 33 public class func getScreenRect()->(width:CGFloat,height:CGFloat){ 34 35 return (UIScreen.mainScreen().bounds.width,UIScreen.mainScreen().bounds.height) 36 } 37 38}
Git地址
http://devonios.com/go/swiftcommon
tips:
本文由wp2blog导入,原文链接:http://devonios.com/scdevice.html