答案 0 :(得分:2)
您可以尝试将其分配给视图
class RightView : UIView {
override init(frame: CGRect) {
super.init(frame: frame)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func draw(_ rect: CGRect) {
guard let context = UIGraphicsGetCurrentContext() else { return }
context.beginPath()
context.move(to: CGPoint(x: rect.maxX, y: rect.minY))
context.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY))
context.addLine(to: CGPoint(x:rect.maxX - 50, y: rect.maxY))
context.closePath()
context.setFillColor(UIColor.white.cgColor)
context.fillPath()
}
override func awakeFromNib() {
super.awakeFromNib()
self.layer.borderColor = UIColor.black.cgColor
self.layer.borderWidth = 1
}
}