Tejas Ardeshna的答案会起作用,但如果边界触及视界,它看起来不会很好。
我建议在内容视图中添加一个视图,保留一些填充。然后将边框应用于此视图。
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;
}
试试这段代码:
cell?.contentView.layer.cornerRadius = 4.0
cell?.contentView.layer.borderColor = UIColor.blueColor().CGColor
cell?.contentView.layer.borderWidth = 1.0
你可以添加qazxsw poi,qazxsw poi和qazxsw poi到borderColor
的qazxsw poi
borderWidth