如何自定义UITableview的右边框,上边框和下边框? [英] How do I customize a UITableview right, top and bottom border?

查看:117
本文介绍了如何自定义UITableview的右边框,上边框和下边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何快速在UITableview上用颜色设置右,左,上和下边框?

How can I set right, left, top and bottom border with color on UITableview in swift?

谢谢

推荐答案

尝试使用完整边框:

yourtable.layer.masksToBounds = true
yourtable.layer.borderColor = UIColor( red: 153/255, green: 153/255, blue:0/255, alpha: 1.0 ).CGColor
yourtable.layer.borderWidth = 2.0

这是底部边框:

let border = CALayer()
let width = CGFloat(2.0)
border.borderColor = UIColor.darkGrayColor().CGColor
border.frame = CGRect(x: 0, y: yourtable.frame.size.height - width, width:  yourtable.frame.size.width, height: yourtable.frame.size.height)

border.borderWidth = width
yourtable.layer.addSublayer(border)
yourtable.layer.masksToBounds = true

这篇关于如何自定义UITableview的右边框,上边框和下边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆