2
votes

I was looking at some animations in my iPhone app and felt like it was kind of ugly. And then I undertsood it: it just doesn't animate through subpixel states.

So, in case I use usual +beginAnimations/+commitAnimations, moving some stuff just a few pixels look "jumpy". How can I avoid it? Are there any flags to make it animate through float coords or whatever?

Just to give you an idea of what I have and what I'm looking for, please refer to the picture:

alt text http://www.ptoing.net/subpixel_aa.gif

Thanks in advance, Anton

3
Can you update the link to your picture?user577537

3 Answers

7
votes

That's funny, but I found that UIImageView animate its content using aniti-aliasing, while edges of the view are not anti-aliased (hard). It seems to be because UIView itself should maintain the same bounds, while subpixel rendering might add to the bound a bit.

So, I ended up just putting an image with some transparent space around the picture, and it all went smooth.

Just don't let UIView cut its contents for you :)

1
votes

You can try deriving the item you're animating from a custom UIView that overrides its drawRect method and sets anti-aliasing on for it then lets the parent draw into it. Something along the lines of:

- (void) drawRect:(CGRect)area
{
  CGContextRef context = UIGraphicsGetCurrentContext();
  CGContextSaveGState(context);
  CGContextSetShouldAntialias(context, true);
  CGContextSetAllowsAntialiasing(context, true);
  [super drawRect:area];
  // We have to turn it back off since it's not saved in graphic state.
  CGContextSetAllowsAntialiasing(context, false);
  CGContextRestoreGState(context);
}

On the other hand, it might be too late in the rendering pipeline by the time you get here, so you may have to end up rolling your own animation scheme that lets you have full control over pixel-positioning.

0
votes

Per Jeeva's comment above, you can make UIView edges render with Anti-aliasing by settings the following option in the info.plist to YES.

Renders with edge antialiasing

Here is the link Jeeva pointed to:

http://www.techpaa.com/2012/06/avoiding-view-edge-antialiasing.html