IPhone animation: how to deal with alias?

I searched for some animations in my iPhone app and felt it was disgusting. And then I figured it out: it just doesn't animate via subpixel states.

So, in case I use the usual beginAnimations / + commitAnimations, moving some material, only a few pixels look "bouncing". How can I avoid this? Are there any flags to make it animate via float coordinates or whatever?

To give you an idea of ​​what I have and what I am looking for, please refer to the figure:

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

Thanks in advance, Anton

+2


source to share


3 answers


It's funny, but I found that the UIImageView animates its content with aniti-aliasing, while the edges of the view are not antialiated (hardcoded). It looks like the UIView itself has to maintain the same borders, while the subpixel rendering might snap to the border a bit.

So in the end I just put an image with transparent space around the painting and everything went smoothly.



Just don't let UIView slice its content for you :)

+7


source


You can try to get the element you are animating from a custom UIView that overrides its method drawRect

and sets anti-aliasing for it and then allows the parents to insert into it. Something like:

- (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 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 might have to flip your own animation scheme to give you full control over pixel positioning.

+1


source


In Per Jeeva's comment above, you can render the edges of the UIView with anti-aliasing using the settings in the info.plist parameter for the YES parameter.

Renders with edge antialiasing

      

Here is the link Jiva points to:

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

0


source







All Articles