Question

I am using a standard UIBUtton where I set border width and a corner radius such as

[button1.layer setCornerRadius: 15.0];
[button1.layer setMasksToBounds:TRUE];
[button1.layer setBorderWidth: 8.0];

As you can see, there are strange artifacts appearing around the rounded corners of the button. Are there any way to get rid of them other then drawing the button manually? enter image description here

Was it helpful?

Solution 2

At the end of the day, the solution that worked for me was to set the border width of the buttons to 0 and then simply draw them on the white background view at the proper offsets. Couldn't take advantage of UIButton's border taking care of the white spacing around each button, but the artifacts are obviously gone.

enter image description here

OTHER TIPS

I'm not sure why that's happening, and there may be an easier solution, but you can use a CAShapeLayer mask to render an image within a certain shape.

See this answer for code on how to so. https://stackoverflow.com/a/18515698/2700842

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top