在使用tableview时,删除安全区域可以通过以下步骤实现:
override func viewDidLoad() {
super.viewDidLoad()
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
}
// 其他初始化设置...
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if #available(iOS 11.0, *) {
let safeAreaInsets = view.safeAreaInsets
tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: safeAreaInsets.bottom, right: 0)
tableView.scrollIndicatorInsets = UIEdgeInsets(top: 0, left: 0, bottom: safeAreaInsets.bottom, right: 0)
}
}
这样做的效果是将tableview的底部安全区域空白部分移除,使其能够充满整个view controller的可见区域。
推荐的腾讯云相关产品和产品介绍链接地址: 腾讯云移动开发平台:https://cloud.tencent.com/product/mps 腾讯云服务器 CVM:https://cloud.tencent.com/product/cvm 腾讯云数据库 MySQL:https://cloud.tencent.com/product/cdb_mysql 腾讯云云原生容器服务:https://cloud.tencent.com/product/tke 腾讯云音视频直播:https://cloud.tencent.com/product/lvb 腾讯云物联网平台:https://cloud.tencent.com/product/iotexplorer 腾讯云对象存储 COS:https://cloud.tencent.com/product/cos 腾讯云区块链服务:https://cloud.tencent.com/product/bcs 腾讯云元宇宙解决方案:https://cloud.tencent.com/solution/universe
领取专属 10元无门槛券
手把手带您无忧上云