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...
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
Post a Comment