1. UIViewController 层次结构
2。约束
-
View Main Content BG
- top、bottom、leading、trailing = 0 wrt superview。
-
lbl1
- top = 10 , trailing = 10 wrt superview
-
dot1
- leading = 10 top = lbl1.top ,水平空间 wrt 到 lbl1 = 10,height = 10 width = 10
-
lbl2
- 垂直间距 wrt
lbl1 = 10 ,leading & trailling = lbl1.leading & lbl1.leading
-
dot2
- 领先 = dot1.leading ,顶部 = lbl2.top ,高度 = 10 宽度 = 10
-
lbl3
- 垂直空间 wrt
lbl2 = 10 ,前导和尾随 = lbl2.leading & lbl2.leading 和底部 = 10 wrt superview
-
dot1
- 领先 = dot2.leading ,顶部 = lbl3.top ,高度 = 10 宽度 = 10
不要忘记每个标签的行数 = 0。并绑定 tableview 委托和数据源 wrt VC。
3.现在您的故事板设计如下所示
4.现在在 VC 中
虚拟数组
var arrList : [[String : String]] = [["lbl1": "Do any additional setup after loading the view, typically from a nib.",
"lbl2": "Do any additional.",
"lbl3": "that can be recreated"],
["lbl1": "Do any additional .",
"lbl2": "Do any additional setup after loading the view, typically from a nib.",
"lbl3": "that can be recreated"],
["lbl1": "Do any additional . Do any additional setup after loading the view, typically from a nib.",
"lbl2": "Do any additional setup after loading the view, typically from a nib.",
"lbl3": "that can be recreated Do any additional setup after loading the view, typically from a nib. Do any additional setup after loading the view, typically from a nib."]]
TableView 委托和数据源
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return 110
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return arrList.count
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
let cell = tableView.dequeueReusableCell(withIdentifier: "TblCell") as! TblCell
let dict = arrList[indexPath.row]
cell.lbl1.text = dict["lbl1"]
cell.lbl2.text = dict["lbl2"]
cell.lbl3.text = dict["lbl3"]
return cell
}
5.最终输出
编辑
如果你用他们的 respec 标签设置了 constant = 5 wr 的点顶部,那么输出如下。