美文网首页Swifty CodingiOS Developer
Swift TableView分割线 复写

Swift TableView分割线 复写

作者: 容错池 | 来源:发表于2016-10-31 15:52 被阅读73次

//先在tableviewcontroller里 把系统自带的分割线隐藏

tableView.separatorStyle=UITableViewCellSeparatorStyle.none

//复写分割线  在自己定义的cell里 重写drawrect方法

overridefuncdraw(_rect:CGRect) {

letcontext:CGContext=UIGraphicsGetCurrentContext()!

context.setFillColor(UIColor.clear.cgColor)

context.fill(rect)

context.setStrokeColor(UIColor.black.cgColor)

context.stroke(CGRect(x:0, y:-0.3, width: rect.size.width, height:0.3))

context.setStrokeColor(UIColor.black.cgColor)

context.stroke(CGRect(x:0, y: rect.size.height, width: rect.size.width, height:0.3))

}

相关文章

网友评论

    本文标题:Swift TableView分割线 复写

    本文链接:https://www.haomeiwen.com/subject/ixjputtx.html