这实际上比看起来更容易,你只需要cornerRadius
为你的单元格主视图设置一个并设置clipsToBounds
为true.对于左/右对齐,您可以使用具有固定约束的两个不同原型,也可以Autolayout constraints
基于单元格以编程方式修改.
对于舍入,请参阅下面使用基本的代码UITableViewCell
(您很可能使用自己的子类,但原理是相同的):
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "myCell", for: indexPath)
cell.backgroundView?.layer.cornerRadius = 5 //set this to whatever constant you need
cell.backgroundView?.clipsToBounds = true
return cell
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
688 次 |
最近记录: |