如何解决我怎样才能在我的自定义表格视图单元格上实现这个 UI
我想在我的 tableviewcell 上实现这个自定义形状,我该怎么做?
解决方法
将 UIBezierPath
与弧一起使用。
将此类添加到您的视图中。
class CellShapeView: UIView {
var fillColor: UIColor = .yellow
private var path: UIBezierPath = UIBezierPath()
override func awakeFromNib() {
super.awakeFromNib()
self.backgroundColor = UIColor.clear
}
override func draw(_ rect: CGRect) {
super.draw(rect)
//For Round corners
UIBezierPath(roundedRect: rect,byRoundingCorners: .allCorners,cornerRadii: CGSize(width: 10,height: 10)).addClip()
path.move(to: CGPoint(x: 0,y: self.frame.size.height))
path.addLine(to: CGPoint(x: 0,y: 0))
path.addLine(to: CGPoint(x: self.frame.size.width,y: self.frame.size.height))
path.move(to: CGPoint(x: self.frame.size.width,y: self.frame.size.height))
//Right Side circle arc
path.addArc(withCenter: CGPoint(x: self.frame.size.width,y: self.frame.size.height/2),radius: 10,startAngle: CGFloat((270 * Double.pi) / 180),endAngle: CGFloat((90 * Double.pi) / 180),clockwise: false)
path.close()
fillColor.setFill()
path.fill()
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。