【发布时间】:2019-04-05 20:49:48
【问题描述】:
我想让表格单元格中的所有内容垂直居中对齐。
我希望我的内容在红线处呈现
我试过了
通过代码
func updateTableViewContentInset() {
let viewHeight: CGFloat = view.frame.size.height
let tableViewContentHeight: CGFloat = placesTable.contentSize.height
let marginHeight: CGFloat = (viewHeight - tableViewContentHeight) / 2.0
self.placesTable.contentInset = UIEdgeInsets(top: marginHeight, left: 0, bottom: -marginHeight, right: 0)
}
override func viewWillAppear(_ animated: Bool) {
updateTableViewContentInset()
}
我试过了
我明白了
结果
甚至通过故事板,但还没有得到我想要的结果。
有什么提示吗?
【问题讨论】:
-
你的意思是你想让每个单元格的单元格内容居中吗?
-
您是否在表格视图单元格元素中添加了垂直居中约束?
-
是的,我愿意。在
css世界里,它叫vertical align center。 -
@DionizB 我是否已经选择了每一个并应用了?还是选择所有 3 个然后应用?
-
全选3个,然后在容器中垂直应用中心
标签: swift uitableview tableview uistoryboard tablecellrenderer