- 针对iphone x 会出现上下的黑框的原因:因为iphone x 的屏幕高度变高了,需要增加一张启动图,尺寸为 1125px * 2436px
iphone x 的屏幕高度变大了,高度增加了145pt====》 变成了 812pt
iphone x 圆角留有 10pt
状态栏 ----> 由原来的20pt,变成了 44pt;
导航栏 ----> 由原来的64pt, 变成了88pt;
底部工具栏 : home indicator 留有 34pt 的边距;
物理分辨率 : 1125px * 2436px
UIView 和 UIViewController 新增属性
safeAreaInsets
: 适用于手动计算。
safeAreaLayoutGuide
: 适用于 自动布局
8.新增安全域
的概念
由原来的状态栏 : status bar
变成: safeAreaInsets.top
【安全域顶部间距】
原来的 64 = 44[导航栏内容区域] + 20 [状态栏区域]
变成 : 88 = 44 [导航栏内容区域] + 44 [safeAreaInsets.top]iOS11 为UIViewController 和UIView 新增了一个方法 :
-(void)viewSafeAreaInsetsDidChange
此方法的第一次调用时间 : 在viewWillAppear
调用之后,在viewwillLayoutSubviews
调用之前若要改变一个 UIViewController 的 safeAreaInsets 值,可以通过设置
addtionalSafeAreaInsets
属性iOS 11 之前,布局时,参照视图top 和 bottom , Top Layout Guide 和 Bottom Layout Guide.
iOS 11 之后, 参照改为 safe Area.
对于滚动视图而言,iOS 11 中,
automaticallyAdjustsScrollViewInsets
被废弃, 决定滚动视图
【eg: UITableView 或者 UIScrollView】 的内容和边距的是 :contentInsetAdjustmentBehavior
和adjustContentInset
iOS 11中如果不实现
-tableView: viewForFooterInSection:
和-tableView: viewForHeaderInSection:
,那么-tableView: heightForHeaderInSection:
和- tableView: heightForFooterInSection:
不会被调用。
这是因为estimatedRowHeight
estimatedSectionHeaderHeight
estimatedSectionFooterHeight
三个高度估算属性由默认的0变成了UITableViewAutomaticDimension
,导致高度计算不对,解决方法是实现对应方法或吧这三个属性设为0。