有問題留言~
iOS11
1.導航欄圖層變化
titleView和barbutton都需要根據(jù)版本適配
titleView最好獨立一個view出來,并且重寫intrinsicContentSize屬性
2.新增安全區(qū)域的概念
iOS 11中Controller的automaticallyAdjustsScrollViewInsets屬性被廢棄了望拖,新增加了安全區(qū)域,如果你的APP中使用的是自定義的navigationbar带到,隱藏掉系統(tǒng)的navigationbar,并且tableView的frame為(0,0,SCREEN_WIDTH, SCREEN_HEIGHT)開始英染,那么系統(tǒng)會自動調(diào)整SafeAreaInsets值為(20,0,0,0)揽惹,如果使用了系統(tǒng)的navigationbar,那么SafeAreaInsets值為(64,0,0,0)四康,如果也使用了系統(tǒng)的tabbar搪搏,那么SafeAreaInsets值為(64,0,49,0)。iPhoneX的SafeAreaInsets值為(88,0,34,0)闪金。
PS:安全區(qū)域是只讀的疯溺,可以通過addtionalSafeAreaInset來擴展安全區(qū)域。
3.scrollView新增的兩個屬性:adjustContentInset和contentInsetAdjustmentBehavior
自行百度
4.手動關閉估算行高
self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;
iPhone X
- 必須修改啟動圖才能占滿整個屏幕毕泌。
- 導航欄和tabbar的高度增加喝检,后面的開發(fā)需要注意動態(tài)改變他的高度嗅辣。
下面的宏直接放在pch文件里面
#define ScreenWidth [[UIScreen mainScreen] bounds].size.width
#define ScreenHeight [[UIScreen mainScreen] bounds].size.height
#define Is_Iphone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define Is_Iphone_X (Is_Iphone && ScreenHeight == 812.0)
#define NaviHeight Is_Iphone_X ? 88 : 64
#define TabbarHeight Is_Iphone_X ? 83 : 49
#define BottomHeight Is_Iphone_X ? 34 : 0
例子:
[view mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.view.mas_top).with.offset(NaviHeight);
make.bottom.equalTo(self.view.mas_bottom).with.offset(-(BottomHeight));
make.left.right.equalTo(self.view);
}];
//有tabbar就用TabbarHeight撼泛,沒有就用BottomHeight
開發(fā)建議
- self.automaticallyAdjustsScrollViewInsets = NO。
- 因為要適配iPhone X動態(tài)改變導航和tabbar的高度澡谭,所以最外層不建議用xib愿题,直接通過代碼適配最好。
新增:
iOS11定位服務 plist里面要增加字段
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>打開定位服務XX將更好的服務于您</string>