CABasicAnimation 运行时 UITextView 滚动缓慢
我在我的应用程序中实现了一个简单的动画。我通过使用 CABasicAnimation
在四个图像帧之间进行交叉淡入淡出来实现动画,该 CABasicAnimation 的 from 和 to 值设置为 (id)(myimage.CGImage)
。动画位于其自己的 CALayer 上,但在其自己的小子视图中滚动弹出的 UITextView 时,文本滚动在帧混合期间非常不稳定,并且在滚动时也会暂停动画。将动画放在自己的线程中是否可以缓解问题,或者这只是与核心动画执行的复杂操作有关?
感谢您的帮助!
I've implemented a simple animation in my app. I achieve the animation by cross-fading between four image frames using a CABasicAnimation
that has a from and to value set to (id)(myimage.CGImage)
. The animation is on its own CALayer but while scrolling a pop-up UITextView in its own small subview, the text scrolling is very jerky during a frame blend, and also pauses the animation while scrolling. Would putting the animation in its own thread alleviate the problem or is this simply to do with a complex operation being done by Core Animation?
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将 UI 动画发送到单独的线程,但对应用程序 UI 的任何实际更新始终由主线程处理/绘制。因此,从这个意义上说,我认为添加额外的线程不会有帮助,特别是如果您已经尝试过,但它仍然没有给出可接受的结果。
我能想到的唯一可能有帮助的是使用 OpenGL 来渲染动画而不是 Core Animation。这将从图片中提取出完整的抽象层,并且因此应该会大大加快速度。当然,完成同样的事情也可能需要更多的代码,因此肯定需要做出权衡。
You can send UI animations to a separate thread but any actual updates to the application's UI are always handled/drawn by the main thread. So in that sense I think adding additional threads is not going to help, particularly if you have tried that already and it still does not give acceptable results.
The only thing I can think of that might help would be to use OpenGL to render your animation instead of Core Animation. That will pull a complete layer of abstraction out of the picture, and should speed things up quite a bit as a result. Of course, it will also likely take a lot more code to accomplish the same thing, so there is certainly a trade-off to be made.