【问题标题】:How to cut one edge of UIView in swift?如何快速切割 UIView 的一个边缘?
【发布时间】:2019-03-05 11:41:39
【问题描述】:

我正在尝试使用 Bezier 路径切割 UIView 的一个边缘,但我无法做到,谁能赐教我?

谢谢

【问题讨论】:

    标签: ios swift transform uibezierpath


    【解决方案1】:

    您可以尝试将其分配给视图

    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
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多