核心情节iPhone动画示例 [英] Core-Plot iPhone Animation Examples

查看:108
本文介绍了核心情节iPhone动画示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究iPhone的核心情节,我很难找到任何实际使用的动画示例。

I've been looking into core-plot for the iPhone and I'm having trouble finding any examples of animation actually being used.

我需要看到什么是一个如何使用核心情节动画在有人点击按钮时为图表添加额外情节的示例。

What I need to see is an example of how to use core-plots animation to add an extra plot to a graph when someone clicks a button.

如果有人可以制作和示例,或者告诉我一个链接到一个,这将是伟大的。

If anyone can produce and example, or show me a link to one, that would be great.

问候,
克雷格

Regards, Craig

推荐答案

Core Plot中的官方CPAnimation类现在只是存根。在某些时候,我们将启用它们的全部功能。

The official CPAnimation classes within Core Plot are just stubs right now. At some point, we'll enable the full functionality of those.

同时,Core Plot中的每个可见元素都是Core Animation CALayer,因此您可以为这些设置动画使用现有的Core Animation方法。例如,如果您有一个名为dataSourceLinePlot的图(就像在测试Core Plot iPhone应用程序中一样),您可以使用0.0的不透明度启动绘图:

In the meantime, every visible element in Core Plot is a Core Animation CALayer, so you can animate these using existing Core Animation methods. For example, if you have a plot called dataSourceLinePlot (like in the test Core Plot iPhone application), you could start the plot off with an opacity of 0.0:

dataSourceLinePlot.opacity = 0.0f;
[graph addPlot:dataSourceLinePlot];

然后设置其不透明度的动画以淡入它:

and then animate its opacity to fade it in:

CABasicAnimation *fadeInAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
fadeInAnimation.duration = 1.0f;
fadeInAnimation.removedOnCompletion = NO;
fadeInAnimation.fillMode = kCAFillModeForwards;
fadeInAnimation.toValue = [NSNumber numberWithFloat:1.0];
[dataSourceLinePlot addAnimation:fadeInAnimation forKey:@"animateOpacity"];

这将在一秒钟的间隔内淡化现有图表上的新图。您也可以执行类似的操作,从侧面为其设置动画或使用变换将其缩放到位。 CATransitions也可用于实现这些效果。

This will fade in a new plot on an existing graph over a one second interval. You could also do something similar to animate it in from a side or use a transform to scale it up into position. CATransitions could also be used to achieve these kind of effects.

编辑(2010年1月17日):Core Plot iPhone测试应用程序现在包含一个淡入淡出的示例 - 在上面描述的动画中。

EDIT (1/17/2010): The Core Plot iPhone test application now contains an example of the fade-in animation described above.

这篇关于核心情节iPhone动画示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆