Swifty CodingiOS Developer

Swift TableView分割线 复写

2016-10-31  本文已影响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))

}

上一篇 下一篇

猜你喜欢

热点阅读