9月份蘋果發(fā)布了IOS11和Iphone X,這一操作系統(tǒng)一硬件對于開發(fā)者適配上面還是造作了不少蛋疼的地方。先來看看IOS 11,這些蛋疼的需要適配的地方:
1、UIScrollView及其子類在IOS 11之前的版本UI顯示完全正常嚣鄙,但是在IOS 11上面會顯示奇葩的界面。
(1)先看一下UITablevIew串结。
原本在VC里面的automaticallyAdjustsScrollViewInsets竟然過期了哑子,在IOS 11下 APPLE推薦使用UIScrollView的contentInsetAdjustmentBehavior屬性進(jìn)行設(shè)置自動計(jì)算滾動視圖的內(nèi)容邊距。
@property(nonatomic,assign) BOOL automaticallyAdjustsScrollViewInsets
在IOS11的SDK下肌割,UIScrollView的這個(gè)屬性
@property(nonatomic) UIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior //這個(gè)屬性是一個(gè)枚舉類型的
{
UIScrollViewContentInsetAdjustmentAutomatic,//scrollView會自動計(jì)算和適應(yīng)頂部和底部的內(nèi)邊距并且在scrollView 不可滾動時(shí),也會設(shè)置內(nèi)邊距.
UIScrollViewContentInsetAdjustmentScrollableAxes, //自動適應(yīng)邊距
UIScrollViewContentInsetAdjustmentNever卧蜓, //和 automaticallyAdjustsScrollViewInsets=NO有著同樣的效果,不計(jì)算內(nèi)邊距
UIScrollViewContentInsetAdjustmentAlways//根據(jù)safeAreaInsets (安全區(qū)域)計(jì)算內(nèi)邊距
}
所以把敞,在IOS 11 下弥奸,需要設(shè)置ScrollView:
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
如果需要全局設(shè)置的話,需要這么設(shè)置:
if (@available(iOS 11.0, *)) {
[[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
}
這樣設(shè)置后使用UITableview 奋早、UICollectionView盛霎、UIScrollview的時(shí)候就不需要再單獨(dú)設(shè)置該屬性了赠橙,因?yàn)閁IView以及他的子類都是遵循UIAppearance協(xié)議的。
轉(zhuǎn)載出處 http://www.cnblogs.com/spider-pei/p/7592906.html