iphone X 适配总结

屏幕未全屏显示

LaunchImage 中添加一个和 iPhone X 相关的启动图片 【图片尺寸:1125 * 2436 】

safe area

safe area

WKWebViewJavascriptBridge

  // 原贴地址:https://github.com/marcuswestin/WebViewJavascriptBridge/issues/278
- (void)webView:(WKWebView *)webView
decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
    // ……
    // Xcode 升级到9后 WKWebViewJavascriptBridge.m 中有个 bug
    // 需要在"decisionHandler(WKNavigationActionPolicyCancel);"后加上 return,否则崩溃。
    // 不升级 Xcode 的话,没问题。
    decisionHandler(WKNavigationActionPolicyCancel);
    return;
}  

automaticallyAdjustsScrollViewInsets

      #define  adjustsScrollViewInsets_NO(scrollView,vc)\
do { \
  _Pragma("clang diagnostic push") \
  _Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
      if ([UIScrollView instancesRespondToSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:")]) {\
          [scrollView   performSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:") withObject:@(2)];\
      } else {\
          vc.automaticallyAdjustsScrollViewInsets = NO;\
      }\
  _Pragma("clang diagnostic pop") \
} while (0)

iPhoneX底部tabbar的高度改变

iphoneX底部多出34P,系统会自动适配

参考文章

App界面适配iOS11
iPhoneX 适配笔记
你可能需要为你的 APP 适配 iOS 11

你可能感兴趣的:(iphone X 适配总结)