SWITF IOS 如何自定义单元格的分割线

来源:互联网 发布:php培训怎么样 编辑:程序博客网 时间:2024/06/06 17:12

1、重写drawRect(rect:CGRect)这个方法

2、将tableview的下划线设置成none

3、修改下划线属性,代码如下


override func drawRect(rect: CGRect) {
        let context = UIGraphicsGetCurrentContext()
        CGContextSetFillColorWithColor(context, UIColor.clearColor().CGColor)
        CGContextFillRect(context, rect)
        println(rect.size.width)
        CGContextSetStrokeColorWithColor(context, UIColor.blueColor().CGColor)
        CGContextStrokeRect(context, CGRectMake(20, rect.size.height, rect.size.width-40, 1))
        
    }


0 0
原创粉丝点击