??中文介绍
随着iPhone X的销售,相信各位土豪很多都已经入手iPhone X了吧,反正我是比较喜欢的,无奈囊中羞涩,只能玩玩模拟器了。
iPhone X 镇楼
1.科普模拟器样式
xcode 9
模拟器自带保护套,有人喜欢有人厌,据说大神都念旧,其实模拟器是可以调的,如果你用的本的屏幕比较小,你可以把鼠标放在模拟器四周调节大小。如果你想找回以前的感觉,请跟着下图做:
2.科普iPhone X的设计图
3.科普启动页的适配
4.导航栏的适配
/************************ 屏幕尺寸 ***************************/
// 屏幕宽度
let JMTWindowWidth = UIScreen.main.bounds.size.width
// 屏幕高度
let JMTWindowHeight = UIScreen.main.bounds.size.height
// iPhone4
let isIphone4 = JMTWindowHeight < 568 ? true : false
// iPhone 5
let isIphone5 = JMTWindowHeight == 568 ? true : false
// iPhone 6
let isIphone6 = JMTWindowHeight == 667 ? true : false
// iphone 6P
let isIphone6P = JMTWindowHeight == 736 ? true : false
// iphone X
let isIphoneX = JMTWindowHeight == 812 ? true : false
// navigationBarHeight
let navigationBarHeight : CGFloat = isIphoneX ? 88 : 64
// tabBarHeight
let tabBarHeight : CGFloat = isIphoneX ? 49 + 34 : 49
5.MJRefresh和继承自UIScrollView的视图的iOS 11适配
OC:
if (@available(iOS 11.0, *)) {
self.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
swift:
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
} else {
self.automaticallyAdjustsScrollViewInsets = false
}
因为哥们是OC写的项目,大家用的时候注意写成Swift。
6.iPhone X 脚底适配
7.iOS 11 下tableView的头视图和脚视图
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return nil
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return nil
}
如果你不想实现viewForHeaderInSection
也不想留白,那么只需要你把self-sizeing
自动估高关闭即可
/// 自动关闭估算高度,不想估算那个,就设置那个即可
self.tableView.estimatedRowHeight = 0
self.tableView.estimatedSectionHeaderHeight = 0
self.tableView.estimatedSectionFooterHeight = 0
8. xcode 无线真机测试
9.iOS 11 真机地图
总结
最近懒得要死,什么都提不起劲,所以文章拖到现在才写。各位请见谅,嘻嘻。有人买X的话,留个言,只要告诉我,玩着美不美就行了。