将视图渲染到 UIImages 是在 iPhone SDK 中处理动画的正确方法吗?

发布于 2024-09-19 18:12:30 字数 491 浏览 1 评论 0原文

我一直在使用 Core Plot 为我正在开发的 iOS 应用程序绘制一些图表。虽然核心图作为图表应用程序非常出色,但在任何类型的用户交互方面它都是性能消耗大的。为了解决这个问题,我开始做以下很多事情:

    UIGraphicsBeginImageContext(view.bounds.size);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

然后在开始动画之前将视图替换为视图的图像,这使得它们更加平滑。

从那时起,我开始在我的应用程序中更多地使用这个想法。在这个项目之前我没有太多的 iOS 经验,也没有真正看过更多专家开发人员的资料。我只是想寻求一些反馈 - 采用这种方法我是否错过了重点?

I've been using Core Plot to draw some charts for an iOS app I've been developing. While core plot is excellent as a charting application, it's a performance hog when it comes to any kind of user interaction. To get around this, I started doing a lot of the following:

    UIGraphicsBeginImageContext(view.bounds.size);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

I would then swap out the view for the image of the view before starting my animations, which made them far smoother.

Since then, I've started using this idea more in my app. I haven't had much iOS experience before this project and haven't really looked at much source from more expert developers. I just wanted to look for some feedback - am I missing the point by taking this approach?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自由如风 2024-09-26 18:12:30

我在我一直致力于在视图之间渲染动画的 OpenGLES 动画框架中广泛使用了它。我不知道你是否没有抓住重点,但如果你是这样,那么我也一定是这样,只要它符合你在申请中想要做的事情,看起来对我来说这是一种做事的好方法。

I use this extensively in an OpenGLES animation framework I've been working on to render animations between views. I don't know that you're missing the point, but if you are, then I must be as well, as so long as it fits within what you want to do in your application, it seems to me like a good way to go about doing things.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文