Using UIBezierPath:byRoundingCorners: with Swift 2 and Swift 3

后端 未结 2 2012
花落未央
花落未央 2021-02-05 07:37

I\'m using this code to make 2 corners of a button rounded.

let buttonPath = UIBezierPath(roundedRect: button.bounds,
                              byRoundingCo         


        
相关标签:
2条回答
  • 2021-02-05 08:20

    Swift 2:

    let buttonPath = UIBezierPath(roundedRect: button.bounds, 
                                  byRoundingCorners: [.TopLeft , .BottomLeft], 
                                  cornerRadii: CGSizeMake(1.0, 1.0))
    

    Swift 3 and Swift 4:

    let buttonPath = UIBezierPath(roundedRect: button.bounds, 
                                  byRoundingCorners: [.topLeft ,.bottomLeft], 
                                  cornerRadii: CGSize(width:1.0, height:1.0))
    
    0 讨论(0)
  • 2021-02-05 08:27

    In this case in swift 2.0 is required to make union of two corners. F. ex.:

    let corners = UIRectCorner.TopLeft.union(UIRectCorner.BottomLeft)
    let buttonPath = UIBezierPath(roundedRect: button.bounds, 
                                  byRoundingCorners: corners,
                                  cornerRadii: CGSizeMake(1.0, 1.0))
    

    Works with Swift 2 and Swift 3

    0 讨论(0)
提交回复
热议问题