I am trying to round top corners using below code
func roundCorners(corners:UIRectCorner, radius: CGFloat) {
let path = UIBezierPath(roundedRect: self.bounds,
byRoundingCorners: corners,
cornerRadii: CGSize(width: radius, height: radius))
let maskLayer = CAShapeLayer()
maskLayer.frame = self.bounds
maskLayer.path = path.cgPath
self.layer.mask = maskLayer
}
use myView.roundCorners(corners:[.topLeft, .topRight], radius: radius)
But it's rounding one side of the view:
this is in a tableView sectionHeader if I scroll down then up it rounded using same code:
And also top discount view corners are rounded using same function.
thank's for help.
Update if I fix the width on the view then it works fine.