缩放多个 CALayer 时出现性能问题
我有两个 CALayer 子类,每个子类都有自己的 drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx 委托。 它们都是简单的图层(一些用 CG 路径绘制的单色形状),但我需要同时缩放大约 12 个实例,并且我在帧速率方面遇到了一些问题。 我将所有图层标记为不透明,以尝试释放一些周期,并尝试使用隐式和显式基本动画(在bounds属性本身上),以及将CA3DTransform矩阵分配给transform属性。
有谁知道在保持良好帧速率的同时快速调整对象大小的好方法?
I have two CALayer subclasses, each with their own drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx delegate. They are both simple layers (some single color shapes drawn with CG paths), but I need to scale about 12 instances simultaneously, and I'm having some issues with frame rates. I marked all of the layers as opaque to try to free up some cycles, and have tried using implicit and explicit basic animations (on the bounds property itself), as well as assigning CA3DTransform matricies to the transform property.
Does anyone know of a good way to quickly resize objects while maintaining a good frame-rate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这听起来并没有超出 iPhone 的能力范围。
一种解决方案可能是将它们渲染为图像并缩放? 这(或多或少)就是 CoreAnimation 要做的事情。 听起来你有一个缺陷——也许你应该发布你的代码,人们可以查看它。
您在哪里执行重绘以及重绘什么?
This doesn't sound to be beyond the capabilities of the iPhone.
One solution might be to render them to an image and scale that? This is (more or less) what CoreAnimation would do. It sounds like you have a defect though - maybe you should post your code and people could look at it.
Where are you performing the redraw and what are you redrawing?
我同意罗杰的观点。
检查您的
drawLayer:inContext:
方法(或您用于绘制的任何内容)被调用的频率。 一个简单的 NSLog 就可以实现这一点。 如果它们不断被调用,请考虑 Roger 的渲染图像并缩放图像的想法。您可能必须启动性能工具才能找到瓶颈。
I agree with Roger.
Check how often your
drawLayer:inContext:
methods (or whatever you use to draw) are being called. A simple NSLog can accomplish that. If they are being called constantly, consider Roger's idea of rendering to an image and scaling that.You will likely have to fire up the performance tools to find your bottleneck.