I'm trying to make this corner radius image...it's not exactly the same shape of the image..any easy answer instead of trying random numbers of width and height ? thanks alot
let rectShape = CAShapeLayer()
rectShape.bounds = self.mainImg.frame
rectShape.position = self.mainImg.center
rectShape.path = UIBezierPath(roundedRect: self.mainImg.bounds, byRoundingCorners: [.bottomLeft , .bottomRight ], cornerRadii: CGSize(width: 50, height: 4)).cgPath
You can use QuadCurve to get the design you want.
Here is a Swift
@IBDesignable
class that lets you specify the image and the "height" of the rounding in Storyboard / Interface Builder:Result with
300 x 200
image view, rounding set to40
:You can try with
UIView
extension. as& use it in
viewWillAppear
like methods where you can get actual frame of UIImageView.Usage: