日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

iOS屏幕尺寸和分辨率了解

發布時間:2023/12/10 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 iOS屏幕尺寸和分辨率了解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、截至目前為止,主流的iOS設備屏幕有以下幾種:

?

--------------- ?iPhone ?---------- -------- ?iPad ------------

?

2、iOS設備屏幕分辨率:(ppi是像素密度單位【像素/英寸】,401ppi表示每英寸上有401個像素)

??

  ppi(pixel per inch)計算,以6Plus為例:

  屏幕分辨率1920 x 1080, ?屏幕尺寸5.5英寸(手機屏幕對角物理線的長度),

  1920 x 1920 + 1080 x 1080 =?4852800, 開根號為:2202.907...

  2202.907 / 5.5 = 400.528 ppi, 大約就是401ppi

?

3、iOS的三種分辨率

  ?1)、資源分辨率:資源圖片的大小,單位是像素。

  ?2)、設計分辨率:邏輯上的屏幕大小,單位是點。我們在Interface Builder設計器中的單位和程序代碼中的單位都是設計分辨率中的“點”。

  ?3)、是以像素為單位的屏幕大小,所有的應用都會渲染到這個屏幕上展示給用戶。

? ? ?iPhone 6 Plus和 6S Plus是最為特殊的設備,資源分辨率與屏幕分辨率的比例是1.15 : 1, 而其他的設備比例是1 : 1。不同的人群關注的分辨率也是不同的,UI設計人員主要關注的是資源分辨率,開發人員主要關注的是設計分辨率,而一般用戶主要關注的屏幕分辨率。

  

?4、獲取設備屏幕信息

  獲取當前移動設備對象:[UIDevice currentDevice]

  UIDevice類所有信息

NS_CLASS_AVAILABLE_IOS(2_0) @interface UIDevice : NSObject + (UIDevice *)currentDevice;@property(nonatomic,readonly,strong) NSString *name; // e.g. "My iPhone" @property(nonatomic,readonly,strong) NSString *model; // e.g. @"iPhone", @"iPod touch" @property(nonatomic,readonly,strong) NSString *localizedModel; // localized version of model @property(nonatomic,readonly,strong) NSString *systemName; // e.g. @"iOS" @property(nonatomic,readonly,strong) NSString *systemVersion; // e.g. @"4.0" @property(nonatomic,readonly) UIDeviceOrientation orientation __TVOS_PROHIBITED; // return current device orientation. this will return UIDeviceOrientationUnknown unless device orientation notifications are being generated. @property(nullable, nonatomic,readonly,strong) NSUUID *identifierForVendor NS_AVAILABLE_IOS(6_0); // a UUID that may be used to uniquely identify the device, same across apps from a single vendor. @property(nonatomic,readonly,getter=isGeneratingDeviceOrientationNotifications) BOOL generatesDeviceOrientationNotifications __TVOS_PROHIBITED; - (void)beginGeneratingDeviceOrientationNotifications __TVOS_PROHIBITED; // nestable - (void)endGeneratingDeviceOrientationNotifications __TVOS_PROHIBITED;@property(nonatomic,getter=isBatteryMonitoringEnabled) BOOL batteryMonitoringEnabled NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED; // default is NO @property(nonatomic,readonly) UIDeviceBatteryState batteryState NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED; // UIDeviceBatteryStateUnknown if monitoring disabled @property(nonatomic,readonly) float batteryLevel NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED; // 0 .. 1.0. -1.0 if UIDeviceBatteryStateUnknown @property(nonatomic,getter=isProximityMonitoringEnabled) BOOL proximityMonitoringEnabled NS_AVAILABLE_IOS(3_0); // default is NO @property(nonatomic,readonly) BOOL proximityState NS_AVAILABLE_IOS(3_0); // always returns NO if no proximity detector @property(nonatomic,readonly,getter=isMultitaskingSupported) BOOL multitaskingSupported NS_AVAILABLE_IOS(4_0);@property(nonatomic,readonly) UIUserInterfaceIdiom userInterfaceIdiom NS_AVAILABLE_IOS(3_2);- (void)playInputClick NS_AVAILABLE_IOS(4_2); // Plays a click only if an enabling input view is on-screen and user has enabled input clicks.@end

?

?ios移動設備類型枚舉判斷:

typedef NS_ENUM(NSInteger, UIUserInterfaceIdiom) {UIUserInterfaceIdiomUnspecified = -1,UIUserInterfaceIdiomPhone NS_ENUM_AVAILABLE_IOS(3_2), // iPhone and iPod touch style UIUIUserInterfaceIdiomPad NS_ENUM_AVAILABLE_IOS(3_2), // iPad style UIUIUserInterfaceIdiomTV NS_ENUM_AVAILABLE_IOS(9_0), // Apple TV style UI };

[UIDevice currentDevice].userInterfaceIdiom == ?UIUserInterfaceIdiomPhone ?// 表示iPhone設備

[UIDevice?currentDevice].userInterfaceIdiom == ?UIUserInterfaceIdiomPad ? ??// 表示iPad設備

[UIDevice?currentDevice].userInterfaceIdiom == ?UIUserInterfaceIdiomTV ?// 表示Apple TV設備

[UIDevice?currentDevice].userInterfaceIdiom == ?UIUserInterfaceIdiomUnspecified ?// 表示未知設備

?

//示例:詳細判斷iPhone設備類型

//詳細判斷iPhone設備信息, 區分橫屏和豎屏if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone){//獲取屏幕尺寸信息CGSize screenSize = [UIScreen mainScreen].bounds.size;//豎屏情況if (screenSize.height > screenSize.width){if (screenSize.height == 568){//iPhone 5/5S/5C (iPod / iPod touch) 等設備 }else if (screenSize.height == 667){//iPone 6 / 6S 等設備 }else if (screenSize.height == 736){//iPone 6 Plus / 6S Plus 等設備 }else{//iPhone 4 / 4S 等設備 }}//橫屏情況if (screenSize.width > screenSize.height){if (screenSize.width == 568){//iPhone 5/5S/5C (iPod / iPod touch) 等設備 }else if (screenSize.width == 667){//iPone 6 / 6S 等設備 }else if (screenSize.width == 736){//iPone 6 Plus / 6S Plus 等設備 }else{//iPhone 4 / 4S 等設備 }}}

//說明:在iPad和iPhone屏幕中,一般會有狀態欄、標簽欄、導航欄(或工具欄)以及內容視圖部分,它們的尺寸也是固定的。狀態欄占20點,導航欄占44點,標簽欄占49點。

?

?ppi(pixel? per? inch): 表示每英寸所包含的像素點數目,數值越高,屏幕能以更高密度顯示圖像

dpr(device pixel ratio): 設備像素比,設備像素 / 設備獨立像素,表示設備獨立像素到設備像素的轉換關系

?

版權聲明


作者:TDX

出處:博客園TDX的技術博客--http://www.cnblogs.com/tandaxia

您的支持是對博主最大的鼓勵,感謝您的認真閱讀。

本文版權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利。

轉載于:https://www.cnblogs.com/tandaxia/p/5060123.html

總結

以上是生活随笔為你收集整理的iOS屏幕尺寸和分辨率了解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。