iPhone: problem rotating a UIView - doesn't look right

非 Y 不嫁゛ 提交于 2020-01-07 02:32:26

问题


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.

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.


回答1:


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.



来源:https://stackoverflow.com/questions/5454017/iphone-problem-rotating-a-uiview-doesnt-look-right

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!