Border radius Swift Ios

0

How can I set a border radius to a UIView in swift , but only in the top part, below it has to be straight

I currently have this:

caja!.layer.cornerRadius = 7.5

but it shows me the border in the whole box

Any solution?

Thanks

    
asked by 22.07.2016 в 11:39
source

1 answer

1

The simplest form is the following:

let maskPath = UIBezierPath(roundedRect: caja.bounds, byRoundingCorners: [.TopLeft, .TopRight], cornerRadii: CGSizeMake(7.5, 7.5))

let maskLayer = CAShapeLayer()
maskLayer.frame = caja.bounds
maskLayer.path  = maskPath.CGPath
caja.layer.mask = maskLayer
    
answered by 22.07.2016 / 13:43
source