sanjihan sanjihan - 1 month ago 20
iOS Question

Using UIBezierPath:byRoundingCorners: with Swift 2 and Swift 3

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

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


It throws an error:


binary operator '|' cannot be applied to two UIRectCorner operands.


How do I use this method in Swift 2.0?

Answer

Swift 2:

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

Swift 3:

let buttonPath = UIBezierPath(roundedRect: button.bounds, byRoundingCorners: [UIRectCorner.topLeft , UIRectCorner.bottomLeft], cornerRadii: CGSize(width:1.0, height:1.0))