1糙捺、iOS 11之前的導(dǎo)航欄的高度是64px(狀態(tài)條+導(dǎo)航欄)耸峭,iOS11之后如果設(shè)置了prefersLargeTitles = YES(默認NO)則為96pt咕别。所以一般不用管。
2、在iOS 11上運行tableView向下偏移64px或者20px币喧,因為iOS 11廢棄了automaticallyAdjustsScrollViewInsets,而是給UIScrollView增加了contentInsetAdjustmentBehavior屬性缕陕。避免這個坑的方法是要判斷
if (@available(iOS 11.0, *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
tableView出現(xiàn) “上拉加載” 的尾巴,也可以用這個方法粱锐。
3、tableView的sectionHeader扛邑、sectionFooter高度與設(shè)置不符怜浅,因為tableView的estimatedRowHeight、estimatedSectionHeaderHeight蔬崩、 estimatedSectionFooterHeight三個高度估算屬性由默認的0變成了UITableViewAutomaticDimension恶座。最簡單的方法就是直接設(shè)置為0。
4沥阳、iPhone X狀態(tài)條由20px變成了44px跨琳,UITabBar由49px變成了83px。設(shè)置布局時y直接寫成64的就要根據(jù)機型設(shè)置桐罕÷鋈茫可以設(shè)置宏
#define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)桂敛,
然后再設(shè)置。
5溅潜、iPhone X啟動圖大小1125 * 2436术唬,如果啟動圖沒有用xib、storyboard并且沒有設(shè)置iPhone X大小滚澜。會出現(xiàn)上下黑框粗仓,不能完全貼合屏幕。
6设捐、幾個常用的宏
#define StatusBarHeight (iPhoneX ? 44.f : 20.f) ?// 電量條 高
#define? StatusBarAndNavigationBarHeight? (iPhoneX ? 88.f : 64.f)? // 導(dǎo)航欄 高
#define? TabbarHeight (iPhoneX ? (49.f+34.f) : 49.f)? // 分欄 高
7借浊、定位不能使用,因為iOS 11新增了兩個新的權(quán)限萝招,NSLocationAlwaysAndWhenInUseUsageDescription 和 NSLocationWhenInUseUsageDescription在plist文件中添加即可蚂斤。