注意你的内容不要被裁切:建议内容为居中对称已不被圆角或传感器等遮挡。也建议使用系统提供的的元素以及自动布局来构建页面获得更好的适配效果。 注意StatusBar的高度:X的状态栏高度会更高,如果有开发伙伴对NavgationBar的位置是通过固定值进行位置的定位的,建议进行APP升级。 如果你的APP是隐藏StatusBar的,建议重新考虑:X为用户在垂直空间上提供了更多展示余地,且状态栏中也包含了用户需要知道的信息,除非能通过隐藏状态栏带给用户额外的价值,否则苹果建议大家将状态栏还给用户。 ——任性地翻译自《Human Interface Guiidelines》
屏幕尺寸我们熟知的iphone 系列开发尺寸概要如下:

图1-1:iPhone各机型的开发尺寸
转化成我们熟知的像素尺寸:

图1-2:每个机型的多维度尺寸
倍图其实就是像素尺寸和开发尺寸的倍率关系,但这只是外在的表现;
倍图核心的影响因素在于PPI(DPI),了解屏幕密度与各尺寸的关系有助于我们深度理解倍率的概念: 链接:《解读:我们说的倍图@2X @3X到底是什么?为什么?》
8在本次升级中,屏幕尺寸和分辨率都遗传了iPhone6以后的优良传统;然而iPhone X 无论是在屏幕尺寸、分辨率、甚至是形状上都发生了较大的改变,下面以iPhone 8作为参照物,看看到底iPhone X的适配 我们要怎么考虑。我们看看iPhone X尺寸上的变化:

图1-3:iPhone 8与X 开发尺寸比对
1.iPhoneX 宏定义
#define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO) #define iOS11 ([[UIDevice currentDevice].systemVersion doubleValue] >= 11.0)
2.聊天界面适配
#import "EaseMessageViewController.h"
//1.添加chatToolbar是否展开判定
//是否已经隐藏底部tool
@property (nonatomic, assign) BOOL isHiddenChatTool;
//2.此处判定 主要是针对 有聊天数据的时候,最底部cell被chatToolbar遮挡问题
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.isViewDidAppear = YES;
[[EaseSDKHelper shareHelper] setIsShowingimagePicker:NO];
if (self.scrollToBottomWhenAppear) {
[self _scrollViewToBottom:NO];
}
self.scrollToBottomWhenAppear = YES;
//3.针对 ipnoneX 的适配
if (iPhoneX) {
//1.table
[UIView animateWithDuration:0.3 animations:^{
CGRect rect = self.tableView.frame;
rect.origin.y = 0;
rect.size.height = self.view.frame.size.height - 46;
rect.size.height = self.view.frame.size.height - 46 - 20;
self.tableView.frame = rect;
}];
[self _scrollViewToBottom:NO];
//2.chatToolbar
self.chatToolbar.frame = CGRectMake(0, self.view.frame.size.height - [EaseChatToolbar defaultHeight]-20, self.view.frame.size.width, [EaseChatToolbar defaultHeight]+20);
}
}3.主要是 发送消息后 有关界面处理
#pragma mark - GestureRecognizer
//点击 手势 隐藏键盘
-(void)keyBoardHidden:(UITapGestureRecognizer *)tapRecognizer
{
if (iPhoneX) {
self.isHiddenChatTool = YES;
}
if (tapRecognizer.state == UIGestureRecognizerStateEnded) {
[self.chatToolbar endEditing:YES];
if (iPhoneX) {
self.chatToolbar.frame = CGRectMake(0, self.view.frame.size.height - [EaseChatToolbar defaultHeight]-20, self.view.frame.size.width, [EaseChatToolbar defaultHeight]+20);
}
}
}
#pragma mark - EMChatToolbarDelegate
//监听chatBarTool frame变化
- (void)chatToolbarDidChangeFrameToHeight:(CGFloat)toHeight
{
[UIView animateWithDuration:0.3 animations:^{
CGRect rect = self.tableView.frame;
rect.origin.y = 0;
rect.size.height = self.view.frame.size.height - toHeight;
if (self.isHiddenChatTool == YES && iPhoneX) {
rect.size.height = self.view.frame.size.height - toHeight - 20;
}
self.tableView.frame = rect;
}];
[self _scrollViewToBottom:NO];
}
//即将开始 输入送信息监听
- (void)inputTextViewWillBeginEditing:(EaseTextView *)inputTextView
{
if (iPhoneX ) {
self.isHiddenChatTool = NO;
}
if (_menuController == nil) {
_menuController = [UIMenuController sharedMenuController];
}
[_menuController setMenuItems:nil];
}4.输入信息后 刷新界面 感觉刷新多次错乱问题
主要是 针对 iOS11的UITableView 适配
#import "EaseRefreshTableViewController.h"
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
[self setEdgesForExtendedLayout:UIRectEdgeNone];
}
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:self.style];
_tableView.accessibilityIdentifier = @"table_view";
_tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.tableFooterView = self.defaultFooterView;
[self.view addSubview:_tableView];
if (iOS11) {
_tableView.estimatedRowHeight = 0;
_tableView.estimatedSectionHeaderHeight = 0;
_tableView.estimatedSectionFooterHeight = 0;
}
_page = 0;
_showRefreshHeader = NO;
_showRefreshFooter = NO;
_showTableBlankView = NO;
}


