iPhone动画:如何抗锯齿?
我在 iPhone 应用程序中查看一些动画,感觉有点难看。然后我明白了:它只是不通过子像素状态进行动画处理。
所以,如果我使用通常的+beginAnimations/+commitAnimations,将一些东西移动几个像素看起来“跳跃”。我怎样才能避免它?是否有任何标志可以通过浮动坐标或其他方式使其具有动画效果?
只是为了让您了解我所拥有的和我正在寻找的内容,请参阅图片:
替代文本 http://www.ptoing.net/subpixel_aa.gif
提前致谢, 安东
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这很有趣,但我发现 UIImageView 使用抗锯齿为其内容设置动画,而视图的边缘没有抗锯齿(硬)。这似乎是因为 UIView 本身应该保持相同的边界,而子像素渲染可能会稍微增加边界。
所以,我最终只是在图片周围放置了一些透明空间的图像,一切都很顺利。
只是不要让 UIView 为你剪切它的内容:)
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 :)
您可以尝试从自定义 UIView 派生动画项目,该 UIView 重写其
drawRect
方法并为其设置抗锯齿功能,然后让父项绘制到其中。大致意思是:另一方面,当您到达这里时,渲染管道可能已经太晚了,因此您可能必须最终滚动自己的动画方案,以让您完全控制像素定位。
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: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.
根据上面 Jeeva 的评论,您可以通过将 info.plist 中的以下选项设置为 YES,使 UIView 边缘使用抗锯齿进行渲染。
这是 Jeeva 指向的链接:
http://www.techpaa .com/2012/06/avoiding-view-edge-antialiasing.html
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.
Here is the link Jeeva pointed to:
http://www.techpaa.com/2012/06/avoiding-view-edge-antialiasing.html