问题描述
我正在向应用程序添加一个简单的UIView。在我使用'transform'属性旋转它之前,它可以正常工作:
I am adding a simple UIView to my app. This works fine, until I use the 'transform' property to rotate it:
myView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];
myView.backgroundColor = [UIColor whiteColor];
myView.transform = CGAffineTransformMakeRotation(-0.2);
[self.view addSubview:myView]; //self.view is just another generic UIView
添加的视图是旋转的,但边缘呈锯齿状-也就是说,边缘尚未消除锯齿。这是我的意思的示例: 。
The added view is rotated, but has jagged edges - i.e. the edges have not been anti-aliased. Here's an example of what I mean: aliased vs. anti-aliased edges.
到目前为止,我还没有找到解决它的任何方法-但可以肯定的是,旋转它并不会那么困难UIView? (同样也适用于UIImageView,我都尝试过。)
So far, I haven't been able to find any way of fixing it - but surely, it can't be that hard just to rotate a UIView? (The same also applies for a UIImageView, I've tried both).
任何帮助或想法都将不胜感激。
Any help or ideas would be much appreciated.
推荐答案
我很难解释发生了什么,但是我知道我已经看到了这个问题,一种解决方案是将您的视图包装在另一个视图中给它一些透明的边框。因此,例如,将视图添加到另一个UIView中,该插图的插入范围约为-4。
I am hard-pressed to explain the WHY of what's going on, but I do know I've seen this issue and one solution is to wrap your view in another or give it some transparent border. So, for example, add the view in another UIView which in inset -4 or so all around.
这篇关于iPhone:旋转UIView时出现问题-看起来不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!