开发者

How to do antialiasing on a rotated UIView (NOT UIImageView)

开发者 https://www.devze.com 2023-04-13 00:25 出处:网络
My issue is basically the the same as this one. I have a UIView and when I rotate it usding CGAffineTransformMakeRotation, the edges are not being antialiased.

My issue is basically the the same as this one. I have a UIView and when I rotate it usding CGAffineTransformMakeRotation, the edges are not being antialiased.

I tried both adding the view as a subview in a bigger UIView and using a transpare开发者_高级运维nt border on the view but none of these worked.

The OP of the aforementioned post solved this by making an image with transparent borders in photoshop and using a UIImageView instead but I cannot do the same because the size of the UIView is determined on runtime.

Does anyone know any solutions to this problem?

Note that this is not a duplicate of this post because I am interested in using a UIView and NOT a UIImageView.


Try setting UIViewEdgeAntialiasing=YES in your App-info.plist


I solved this by creating a 3x3 px image in photoshop. The center pixel of the image has the color I wanted my background to have and the rest of the pixels are transparent. Then I was able to use an instance of UIImageView and to define the frame size at runtime by using the -stretchableImageWithLeftCapWidth:topCapHeight: method.

This solution, of course still does not work for UIViews but that way you can circumvent the "variable size" issue and use a UIImageView instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消