iPhone X 屏幕适配
来源:互联网 发布:free mobile java动漫 编辑:程序博客网 时间:2024/05/17 03:39
今天升级xcode 9, 试了试iPhone X, 结果没有看到我预期的全屏效果,上下都没有显示全.
思忖片刻后想起我的启动图用的是LaunchImage, 而且只有四套, 没有5.8寸的,
注:如果用的是LaunchScreen.storyboard, 是不会因为缺少某个尺寸的启动图而显示不对的
然后我便生成了一张1125 × 2436 的启动图,
但是不知道为何, 我的LaunchImag里面没有添加5.8寸的图片的位置,既然不能拖, 只好来硬的了,show in finder 直接把图片弄在LaunchImag文件下,并在Contents.json中images中添加
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "2436h",
"filename" : "Default-812h@3x.png",
"minimum-system-version" : "11.0",
"orientation" : "portrait",
"scale" : "3x"
},
filename 取决于你自己起什么名了
然后再启动就OK了, 打印的屏幕大小为 375x812;
自动布局时需要注意一下几点
1. iOS11 以前,我们布局时,视图的 top和 bottom一般参照的是 Top Layout Guide 和 Bottom Layout Guide
2. iOS11 以后,那两个参照已经 deprecated (过时)了,而被 Safe Area 取
3. Safe Area 要求最低支持 iOS9.0
顶部导航栏的高度是44+44, 底部有34的触摸区域, 效果如下
我们再计算导航栏高度的时候可以写一个宏
#define iphoneX ([UIScreen mainScreen].bounds.size.height>800.0f)#define kNavigationHeight (iphoneX ? 88 : 64)
对于ScrollView ,iOS 11引入了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));使用的时候根据需求设置枚举值就行
我自己是这么用的,因为这样设置可以保证scrollView的内容,都显示在安全区
if (@available(iOS 11.0, *)) { _scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAlways; }
- iphone X 屏幕适配
- iPhone X 屏幕适配
- unity3d 屏幕适配 iPhone X 解决方案
- iPhone X 屏幕适配,没有铺满屏幕的情况
- iphone X 的屏幕适配(简单版)
- iPhone屏幕适配
- iPhone屏幕适配
- Iphone适配屏幕大小
- iPhone的屏幕适配
- unity3d iPhone X 适屏代码 屏幕适应方案
- unity3d iPhone X 适屏代码 屏幕适应方案
- iPhone X全屏适配
- iPhone X 的适配
- iphone x 适配问题
- cocos2d-x 屏幕适配
- Cocos2d-x 屏幕适配
- cocos2d-x屏幕适配
- Cocos2d-x 屏幕适配
- H5 HTML代码编写规范及注意要点
- 正则表达式学习
- 前端实现office文档阅览的方法(整理)
- Android Seekbar透明滑动球thumb 不透明的解决办法
- response对象
- iPhone X 屏幕适配
- 好久没逛CSDN了
- IO流
- Java 按行读取文件按行写入文件并以空格分割字符串
- ld: library not found for -lXXXXX 编译问题的解决方法
- ES6第二章 关于“变量的解构赋值”不得不说的事~
- 轮播图配置
- ICN(Information centric networking)体系结构和技术实现
- webapi返回的json数据出现k__BackingField