//iPhone_X中 UIView的frame设置--> 一个全屏的UIView
let is_iphoneX = (UIScreen.main.bounds.height == 812.0)//
let Y: CGFloat = is_iphoneX ? 0 + 24.0 : 0//距上距离-->没有导航栏下;有导航栏需要 -64
let H: CGFloat = is_iphoneX ? (view.bounds.height - Y - 34) : view.bounds.height - Y//高度
let customView = UIView(frame: CGRect(x: 0, y: Y, width: view.bounds.width, height: H))
//iPhone X 中tableView的frame设置 --> 一个全屏的tableView
let Y: CGFloat = is_iphoneX ? 64.0 + 24.0 : 64.0//距上距离
let H: CGFloat = is_iphoneX ? (view.bounds.height - Y - 34) : view.bounds.height - Y//高度
let tv = UITableView.init(frame: CGRect(x: 0, y: Y, width: view.bounds.width, height: H), style: .plain)
本文介绍如何针对iPhone X进行UIView及TableView的布局调整,通过Swift代码实现不同设备上的自适应显示效果。具体包括视图的高度计算以及距顶部的距离设定。
331

被折叠的 条评论
为什么被折叠?



