make your desired view corner round

PHOTO EMBED

Mon Feb 07 2022 07:41:03 GMT+0000 (Coordinated Universal Time)

Saved by @hasnat #ios #swift #round #corner #view #viewround

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

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