日本国产亚洲-日本国产一区-日本国产一区二区三区-日本韩国欧美一区-日本韩国欧美在线-日本韩国欧美在线观看

當前位置:雨林木風下載站 > 蘋果教程教程 > 詳細頁面

iOS 適配iPhone X的辦法_IOS

iOS 適配iPhone X的辦法_IOS

更新時間:2024-04-09 文章作者:未知 信息來源:網絡 閱讀次數:

因為iPhone X奇特的劉海存在,iOS11之后系統深化了“安全區域”概念,安全區域就是從屏幕上切除最大的矩形之外的區域。iOS11后UIScrollView新增contentInsetAdjus...

因為iPhone X奇特的劉海存在,iOS11之后系統深化了“安全區域”概念,安全區域就是從屏幕上切除最大的矩形之外的區域。

iOS11后UIScrollView新增contentInsetAdjustmentBehavior屬性,默認配置UIScrollViewContentInsetAdjustmentAutomatic,效果上就是沒使用安全區域。若針對具體頁面需要使用安全區域,可以查看API中新增加的那些屬性。

/** 
 * 適配iPhone X的安全區域 
 * isUse = 1 表示使用安全區域 
 * isUse = 0 表示不使用安全區域 
 */ 
+ (void)adaptationSafeAreaWith:(UIScrollView *)sv useArea:(NSInteger)isUse { 
  if ([[sv class] isSubclassOfClass:[UIWebView class]]) { 
    UIWebView *webView = (UIWebView *)sv; 
    for (UIView *aView in [webView subviews]) { 
      if ([aView isKindOfClass:[UIScrollView class]]) { 
        sv = (UIScrollView *)aView; 
        break; 
      } 
    } 
  } 
#ifdef __IPHONE_11_0 
  if ([sv respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) { 
    if (isUse) { 
      if (@available(iOS 11.0, *)) { 
        sv.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; 
        if ([[sv class] isSubclassOfClass:[UITableView class]]) { 
          UITableView *tv = (UITableView *)sv; 
          [tv setInsetsContentViewsToSafeArea:NO]; 
        } 
      } else { 
        // Fallback on earlier versions 
      } 
    } else { 
      if (@available(iOS 11.0, *)) { 
        sv.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAlways; 
      } else { 
        // Fallback on earlier versions 
      } 
    } 
  } 
#endif 
} 
typedef NS_ENUM(NSInteger, UIScrollViewContentInsetAdjustmentBehavior) { 
  UIScrollViewContentInsetAdjustmentAutomatic,   // Similar to .scrollableAxes, but for backward compatibility will also adjust the top & bottom contentInset when the scroll view is owned by a view controller with automaticallyAdjustsScrollViewInsets = YES inside a navigation controller, regardless of whether the scroll view is scrollable 
  UIScrollViewContentInsetAdjustmentScrollableAxes, // Edges for scrollable axes are adjusted (i.e., contentSize.width/height > frame.size.width/height or alwaysBounceHorizontal/Vertical = YES) 
  UIScrollViewContentInsetAdjustmentNever,     // contentInset is not adjusted 
  UIScrollViewContentInsetAdjustmentAlways,     // contentInset is always adjusted by the scroll view's safeAreaInsets 
} API_AVAILABLE(ios(11.0),tvos(11.0)); 

以上這篇iOS 適配iPhone X的方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持本站。

您可能感興趣的文章:
  • 淺談iphone X的簡單適配問題(推薦)
  • iPhone X官方文檔的適配學習詳解
  • iOS11和iPhoneX適配的一些坑
  • 關于適配iOS11和iPhoneX的一些事


溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

主站蜘蛛池模板: 五月天激激婷婷大综合丁香 | 久久综合九色综合98一99久久99久 | 精选国产门事件福利在线观看 | 欧美四虎 | 91精品啪在线观看国产色 | 午夜在线视频免费 | 99视频有精品视频免费观看 | 亚洲日本中文字幕在线 | 久草视频资源 | 浮力影院欧美第一页 | 色婷婷久久综合中文久久一本 | 国产成人高清视频 | 欧美国产伦久久久久 | 欧美人视频| 一道精品视频一区二区三区男同 | 欧美一区三区 | 久久狠狠色狠狠色综合 | 精品成人在线观看 | 亚洲大片免费看 | 欧美乱性视频 | 色老头网站久久网 | 久久xx| 四虎国产在线观看 | 国产精品久久久久9999小说 | 九九在线精品视频xxx | 久久精品亚洲欧美日韩久久 | 俄罗斯精品18videosex性 | 亚洲视频在线网 | 欧美一级鲁丝片免费看 | 国产精品久久久久9999高清 | 国内精品久久久久丫网址 | 久久久伊香蕉网站 | 一区二区三区毛片免费 | 丁香色婷婷国产精品视频 | 中文字幕在线看片成人 | 在线成人综合色一区 | 久久久久久久久网站 | 午夜小片 | 中国毛片网 | 国产精品啪 | 国产1区精品 |