override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let height = self.navigationController?.navigationBar.frame.size.height
return view.frame.size.height - height!
}
I want to change the cell size — I use only one cell.
My purpose is to fit the screen. However, in my case, the cell is scrolled.
I think it is necessary to calculate the safe area. What if I do not have a smaller or larger screen?
Please calculate like below for height, includes safe area code.
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let height = view.bounds.height - view.safeAreaInsets.top - view.safeAreaInsets.bottom
return height!
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.