美文网首页
swift -tableviewCell 分割线

swift -tableviewCell 分割线

作者: 精神病患者link常 | 来源:发表于2018-09-19 17:38 被阅读25次
QQ20180919-173457.gif

在cell添加了一个View,充当分割线,但是在点击的时候会出现闪的情况。

解决方法:去掉分割线的View。通过override func draw(_ rect: CGRect)进行绘制一条分割线

override func draw(_ rect: CGRect) {
        
        //获取绘图上下文
        guard let context = UIGraphicsGetCurrentContext() else {
            return
        }
        
        context.setFillColor(UIColor.init(hexString: "#F2F2F2").cgColor)
        context.fill(CGRect.init(x: 0, y: 135, width: Tools.screenWidth(), height: 8))        
    }

最后效果


QQ20180919-173752.gif

相关文章

网友评论

      本文标题:swift -tableviewCell 分割线

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