最佳答案
Tejas Ardeshna 的答案会奏效,但如果边界接触到 View 边界,它看起来就不会好看。
我建议在内容 View 中添加一个 View ,并保留一些填充。然后将边框应用于此 View 。
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCellWithIdentifier("UITableViewCell", forIndexPath: indexPath) as UITableViewCell
if cell.viewWithTag(100) == nil
{
let view = UIView()
view.frame = CGRectInset(cell.contentView.bounds, 4 , 4)
view.layer.borderWidth = 1
view.layer.cornerRadius = 4
view.layer.borderColor = UIColor(red: 0, green: 0, blue: 0.6, alpha: 1).CGColor
cell.contentView.addSubview(view)
}
return cell;
}
关于ios - 表格单元格圆角边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35909460/