Home > Software engineering >  Circular UIView achieved with cornerRadius looks blocky
Circular UIView achieved with cornerRadius looks blocky

Time:09-19

In my application, I usecornerRadius to apply a circular mask effect to a UIView.

view.layer.cornerRadius = view.frame.height / 2
view.clipsToBounds = true

However, when I use this method, the result looks blocky. I enlarged this example of the issue, so the issue can be seen better (especially on the top):

An example of the blockiness with a plain black image.

What causes this and how can I fix this?

CodePudding user response:

Modify your UIView's frame size: change every value to a whole number, so the graphics engine can calculate the image with a perfect result.

  • Related