【问题标题】:sequencing UIImageView frame(s) animation & CGTransform animation排序 UIImageView 帧动画和 CGTransform 动画
【发布时间】:2009-10-22 19:34:30
【问题描述】:

我想要一些关于对一些动画进行排序的策略方面的帮助。

我继承了 UIImageView 以便我可以在图像上编写一些自定义动画动作。我实现了一些方法用作我可以在我的图像上调用的操作 示例:

-(void)rotateAnim; //rotates the image by a few degrees using a CGAffine Transform

-(void)numbersFlashAnim; //uses the UIImageVew.animationImages array for a 14 frame animation.

-(void)moveLeftAnim; //uses another CGAffine Transform to change the imageView's position.

在我的 viewDidLoad 方法中,我创建了一个 UIImageView 子类的实例。有哪些方法可以按顺序调用这些动画?

我正在考虑使用 NSTimer 来处理动画,但不确定是否可以编写 NSTimer 对象来处理多个方法调用。

示例:

[imageView rotateAnim]; //when this animation is done, I want to call:
[imageView numbersFlashAnim];

我见过几个关于使用 NSTimer 的问题,但没有一个与这个问题特别相关。注意:我看到苹果网站上的开发文档还建议使用 performSelector:withObject:afterDelay: 在某些情况下,但想知道这是否会提供足够的灵活性。

另外,我已经看过 Cocos2d 框架,虽然我可以使用他们的方法~(Sequence actions: etc, ) 我选择用 UIKit/Foundation 等来解决这个问题。

【问题讨论】:

    标签: iphone objective-c uiimageview nstimer


    【解决方案1】:

    你使用动画吗?我的意思是你可以在里面旋转你的图像 [UIView beginAnimations:(NSString *)animationID context:(void *)context] 块。在那里您可以添加一个委托方法,该方法将在当前动画结束后调用。在那里你可以调用你的号码FlashAnim。 (对不起我的英语;-))

    【讨论】:

    • 是的,我使用了一个动画块并包装在一个方法中,这样我就可以用一行代码调用整个动画。我没有添加任何代表。所以我会检查一下。我可以将动画委托也用于animationFrames吗?
    • 嗯。对不起,但我不明白你在animationFrames下是什么意思。您可以在动画块内调用 imageView 的旋转。然后你可以在动画的第二部分设置一个方法,在你的动画完成后触发。
    猜你喜欢
    • 2012-09-16
    • 1970-01-01
    • 1970-01-01
    • 2012-02-08
    • 2018-06-16
    • 1970-01-01
    • 2012-02-09
    相关资源
    最近更新 更多