0

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.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
Jordan Smith
  • 10,310
  • 7
  • 68
  • 114

1 Answers1

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.

ZaBlanc
  • 4,679
  • 1
  • 35
  • 38
  • Thanks, I'd already tried placing it in another view which didn't work. What did work though was making an image with transparent borders in photoshop and using a UIImageView instead. – Jordan Smith Mar 28 '11 at 02:55