when a UIView is rotated, it's borders look incredible ugly. There's no antialiasing happening at all. Also if it's a UIImageView, no antialiasing happens when rotating the transform matrix. Is there a way to achieve smooth edges and smooth rotation of images?
+4
A:
For a UIImageView, add a one-pixel transparent border around the image. This will cause the edges of your image to be on the "inside", and because the inside pixels are interpolated when rotating, the borders will magically become antialiased. This also works for rotating UIButtons that have a custom image.
vocaro
2009-09-03 16:34:14
For the longest time, I searched for a way to “add a one-pixel transparent border” around my UIImageView. I tried enlarging the `.frame` by 2 `CGFloat` s and varoious other methods until I figured you probably meant: add the border to the loaded UIImage (in my case constructed from a PNG file).
Raphael Schweikert
2010-09-06 17:32:48
no I reckon he means set borderWidth on the view.layar (needs QuartzCore import) - see this post for more details: http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/
tigermain
2010-09-29 23:36:33
Either way will work. You can add the border statically to the image itself, or add it dynamically to the UIImage at runtime, as described in my blog post.
vocaro
2010-10-06 05:13:44