UIBezierPath Subclass Initializer

后端 未结 2 2036
长情又很酷
长情又很酷 2020-12-10 20:13

I\'m trying to create a subclass of UIBezierPath to add some properties that are useful to me.

class MyUIBezierPath : UIBezierPath {
   var selectedForLazo :         


        
2条回答
  •  醉酒成梦
    2020-12-10 21:12

    I found this simple workaround that seems to do its job.

    class MyUIBezierPath : UIBezierPath {
       var selectedForLazo : Bool! = false
    
       override init() {
           super.init()
       }
    
       init(rect: CGRect){
           super.init()
           self.appendPath(UIBezierPath(rect: rect))
       }
    
       init(roundedRect: CGRect, cornerRadius: CGFloat) {
           super.init()
           self.appendPath(UIBezierPath(roundedRect: roundedRect, cornerRadius: cornerRadius))
       }
    
       required init(coder aDecoder: NSCoder) {
           super.init()
       }
    }
    

    Please post other solutions because they'll surely be better than mine.

提交回复
热议问题