本文主要簡單談談并收集一些關于 iOS 11 & iPhone X 的適配及設計指南。
iPhone X
眾所周知,iPhone X 屏幕與其他的 iPhone 設備均不同,蘋果稱 iPhone X 的屏幕為超級視網膜顯示屏。
- 在 iPhone X 上 1pt 相當于 3x3 px,也就是我們常說的 @3x,同 Plus 機型。
- iPhone X 的屏幕尺寸為 375x812 pt(即 1125×2436 pix)。iPhone X 比 4.7 寸機型屏幕多出 145 pt。
- iPhone X 最引人注意的就是它的屏幕,沒錯...帶劉海的屏幕。至于適配問題,本文不做過多解說,本文末尾會給出相關資料。
Don't mask or call special attention to key display features. Don't attempt to hide the device's rounded corners, sensor housing, or indicator for accessing the Home screen by placing black bars at the top and bottom of the screen. Don't use visual adornments like brackets, bezels, shapes, or instructional text to call special attention to these areas either.
注意:根據 Human Interface Guidelines for iPhone X 規范,不要試圖去隱藏屏幕的圓角、劉海等。前段時間 GitHub 上小火了一個 Swift 庫 NotchKit,專門用于隱藏 iPhone X 的劉海。筆者建議先別急著集成公司項目,這種做法可能會被蘋果拒絕(違反了 HIG 條例),不過小伙們可以集成至個人項目提交審核試試。
安全區域(SafeArea)
無導航欄時
豎屏
豎屏情況下并且無導航欄時,上下安全邊距分別為 44pt/34pt,即安全區域寬高為 375pt/734pt。
橫屏
橫屏情況下并且無導航欄時,上下安全邊距分別為 0pt/21pt,左右安全邊距為 44pt/44pt,即安全區域寬高為 724pt/354pt。
有導航欄時
在 iOS 11 中導航欄有個新特性 —— 大標題,直接上代碼:
Objective-C:
if (@available(iOS 11.0, *)) {
self.navigationController.navigationBar.prefersLargeTitles = YES;
self.navigationController.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeAutomatic;
}
Swift:
if #available(iOS 11.0, *) {
navigationController?.navigationBar.prefersLargeTitles = largeTitle
navigationController?.navigationItem.largeTitleDisplayMode = .automatic
}
豎屏
當沒有開啟大標題且有導航欄時,上下安全邊距分別為 88pt/34pt,即安全區域寬高為 375pt/690pt。
開啟大標題時,上下安全邊距分別為 140pt/34pt,即安全區域寬高為 375pt/638pt。
橫屏
不管有沒有開啟大標題,橫盤狀態下一樣,上下安全邊距分別為 32pt/21pt,左右安全邊距為 44pt/44pt,即安全區域寬高為 724pt/322pt。
機型尺寸
定位相關
在 iOS 11 中必須支持 When In Use
授權模式(NSLocationWhenInUseUsageDescription),在 iOS 11 中,為了避免開發者只提供請求 Always
授權模式這種情況,加入此限制,如果不提供When In Use
授權模式,那么 Always
相關授權模式也無法正常使用。
如果要支持老版本,即 iOS 11 以下系統版本,那么建議在 info.plist 中配置所有的 Key(即使 NSLocationAlwaysUsageDescription 在 iOS 11及以上版本不再使用):
- NSLocationWhenInUseUsageDescription
- NSLocationAlwaysAndWhenInUseUsageDescription
- NSLocationAlwaysUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription 為 iOS 11 中新引入的一個 Key。
資料集
- iPhone X HIG
- Adaptivity & Layout
- Image size & Resolution
- WWDC17: What's New in Location Technologies ?
- Designing for iPhone X
- Building Apps for iPhone X
- 關于iPhone X 的適配
- iOS11 & iPhone X 適配指南
- 你可能需要為你的 APP 適配 iOS 11
- 適配iOS11,適配iPhoneX,適配安全區的幾個文章和宏
- 為 iOS 11 適配工具欄(UIToolBar)
- 簡書 App 適配 iOS 11
- iOS 安全區域適配總結
- Update Apps for iPhone X
- 手管 iPhone X 的適配總結