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

store cgpoint in userdefaults iOS swift

Invalid bundle error while upload the app to the app Store