Set the corner radius to topLeft and topRight to UIView iOS swift

Solution:

Add function to layoutsubviews to your view..Set the top left and right corners to the view roundTopCorners...

    override func layoutSubviews() {
        super.layoutSubviews()
        roundTopCorners(corners: [.topLeft, .topRight], radius: 3.0)
    }

extension UIView {
    func roundTopCorners(corners: UIRectCorner, radius: CGFloat) {
        let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
        let masking = CAShapeLayer()
        masking.path = path.cgPath
        layer.mask = masking
    }
}

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Saved Image in document directory and save path in coredata not able to fetch the image file iOS swift