国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

iOS 適配iPhone X的方法

2019-10-21 18:42:27
字體:
來源:轉載
供稿:網友

因為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的方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到IOS開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 丰宁| 郁南县| 贞丰县| 麻栗坡县| 兴城市| 沧州市| 微山县| 宁明县| 芒康县| 四会市| 抚顺县| 桃江县| 专栏| 清水县| 金川县| 汕尾市| 阿鲁科尔沁旗| 陇南市| 云南省| 化德县| 阿克苏市| 水城县| 稷山县| 双鸭山市| 安宁市| 潮安县| 建瓯市| 灵川县| 抚松县| 健康| 漳州市| 营口市| 苍梧县| 保定市| 康马县| 寿阳县| 湖南省| 林州市| 都兰县| 砚山县| 新化县|