如何在旋转视图上进行抗锯齿? [英] How to do antialiasing on a rotated view?

查看:93
本文介绍了如何在旋转视图上进行抗锯齿?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

Possible Duplicate:
Any quick and dirty anti-aliasing techniques for a rotated UIImageView?

当一个UIView被旋转,它的边框看起来难以置信的丑陋。没有反锯齿事件发生。此外,如果它是一个UIImageView,旋转变换矩阵时不会发生抗锯齿。是否有实现平滑边缘和平滑旋转图像的方法?

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?

推荐答案

对于UIImageView,添加一个像素的透明边框围绕图像。这将导致图像的边缘在内部,并且因为内部像素在旋转时被插值,边缘将奇迹般地变为抗锯齿。这也适用于旋转具有自定义图像的UIButtons。

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.

这篇关于如何在旋转视图上进行抗锯齿?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆