最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

iOS 適配iPhone X的方法

 更新時(shí)間:2018年01月06日 17:34:16   投稿:jingxian  
下面小編就為大家分享一篇iOS 適配iPhone X的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

因?yàn)閕Phone X奇特的劉海存在,iOS11之后系統(tǒng)深化了“安全區(qū)域”概念,安全區(qū)域就是從屏幕上切除最大的矩形之外的區(qū)域。

iOS11后UIScrollView新增contentInsetAdjustmentBehavior屬性,默認(rèn)配置UIScrollViewContentInsetAdjustmentAutomatic,效果上就是沒(méi)使用安全區(qū)域。若針對(duì)具體頁(yè)面需要使用安全區(qū)域,可以查看API中新增加的那些屬性。

/** 
 * 適配iPhone X的安全區(qū)域 
 * isUse = 1 表示使用安全區(qū)域 
 * isUse = 0 表示不使用安全區(qū)域 
 */ 
+ (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的方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

昌邑市| 永登县| 密云县| 九寨沟县| 永川市| 连山| 潼关县| 专栏| 琼海市| 增城市| 潜江市| 饶平县| 玛纳斯县| 荃湾区| 锡林浩特市| 敦化市| 招远市| 房产| 锡林浩特市| 临沂市| 赣榆县| 买车| 临朐县| 临汾市| 钟祥市| 庆阳市| 工布江达县| 中西区| 阿克陶县| 乐陵市| 青浦区| 楚雄市| 定南县| 鄂州市| 环江| 随州市| 渭南市| 托克逊县| 夏邑县| 漾濞| 正阳县|