【发布时间】:2018-12-08 08:30:03
【问题描述】:
这是我的代码,但不起作用!
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! MyChatCell
var frame = cell.frame
if(indexPath%2 == 0){
frame.size.width = CGFloat(200)
} else {
frame.size.width = CGFloat(100)
}
cell.frame = frame
return cell
}
我想将单元格宽度更改为每个单元格 100 或 200
但是frame.size.width 不行
【问题讨论】:
-
阅读:stackoverflow.com/questions/494562/… 您还可以在具有动态高度的单元格中使用自动布局。
标签: swift uitableview tableview frame