1. 显示黑条,即没有沾满屏幕,对于这个问题,添加一张 1125 * 2436的启动图即可.
2.关于 navi 在 iPhone X 上是88. 通过对 navi 图层的观察, navi 是从44开始的.其背景是向上偏移44,和之前状态栏的思路是一样的,只是偏移量不一样.
3.开发尺寸是375 * 812
ps: 如下面,由于要在 navi 上添加渐变的背景图,要控制 navi 的高
- (UIImageView *)alphaView {
if (!_alphaView) {
CGRect frame = self.navigationBar.frame;
CGFloat h = SCREEN_HEIGHT == 812 ? 88 : 64;
UIImageView *alphaView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, h)];
alphaView.image = [UIImage imageNamed:@"bg_gradient"];
[self.navigationBar.subviews.firstObject insertSubview: alphaView atIndex:0];
_alphaView = alphaView;
}
return _alphaView;
}
4. tabbar的高度为83
5.当使用 ScrollView 时,默认偏移量是88;
iOS11上automaticallyAdjustsScrollViewInsets = false
这句代码失效
在 iOS11中添加了新的属性contentInsetAdjustmentBehavior
,这个属性是个枚举值
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));
/*
automatic 和scrollableAxes一样,scrollView会自动计算和适应顶部和底部的内边距并且在scrollView 不可滚动时,也会设置内边距.
scrollableAxes 自动计算内边距.
never不计算内边距
always 根据safeAreaInsets 计算内边距
*/
所以我们要对 scrollview 进行如下设置,才能解决偏移88的问题.
if #available(iOS 11.0, *) {
scrollerView.contentInsetAdjustmentBehavior = .never
}