Kumar sonu Kumar sonu - 1 year ago 146
iOS Question

Corner radius issue with UIButton

I want to add a corner radius to a UIButton. It is working fine but a problem occurs when I add image to it.

It does not round its corners with images, the image is shown in full rectangle form.

Please see the image, I have used the corner radius with red color and the output is as follow:

enter image description here

Please help.

Answer Source

Did you try to use set the masksToBounds: property? Fore example:

CALayer *layer = [myView layer];
[layer setMasksToBounds:YES];
[layer setCornerRadius:8.0];

That should do the trick.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download