开发者

UIImageView Delay or revert to different frame

开发者 https://www.devze.com 2023-04-11 11:10 出处:网络
Ok so I have been searching and have been unable to find an answers to this problem.(And I assume I can\'t find it because it is a very easy answer that everyone seems to know but me.)I am creating an

Ok so I have been searching and have been unable to find an answers to this problem. (And I assume I can't find it because it is a very easy answer that everyone seems to know but me.) I am creating an app for IOS, where there is some opening animation and then I need the opening animation to stop and then different animation to take place instead. So I have the opening animation working fine and I have it stopping on the last frame. How do I get the new animation to start at the end of the opening animation? I am using UIImageView under the viewDidLoad() function. Here is my code for the ViewContro开发者_JS百科ller.m file:

@implementation ViewController
@synthesize hook_drop_one;
@synthesize hook_swing_one;

- (void)viewDidLoad

{
    [super viewDidLoad];

    hook_drop_aone=[[NSMutableArray alloc] init];
    for (int i=1; i<16; i++) {
        NSString *hookpic=[NSString stringWithFormat: @"hook%d.png",i];
        UIImage *img = [UIImage imageNamed:hookpic];
        if (img) [hook_drop_aone addObject:img];
        [hook_drop_one setAnimationImages:(hook_drop_aone)];
        [hook_drop_one setAnimationDuration:0.9f];
        [hook_drop_one setAnimationRepeatCount:1];
        [hook_drop_one startAnimating];
    }

    hook_swing_aone=[[NSMutableArray alloc] init];
    for (int i=1; i<230; i++) {
        NSString *hookswingpic=[NSString stringWithFormat: @"hookswing%d.png",i];
        UIImage *img = [UIImage imageNamed:hookswingpic];
        if (img) [hook_swing_aone addObject:img];
        [hook_swing_one setAnimationImages:(hook_swing_aone)];
        [hook_swing_one setAnimationDuration:10.2f];
        [hook_swing_one startAnimating];
    }
}

My code fro the ViewController.h file:

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController{
    IBOutlet UIImageView *hook_drop_one;
    NSMutableArray *hook_drop_aone;
    IBOutlet UIImageView *hook_swing_one;
    NSMutableArray *hook_swing_aone;
}

@property (nonatomic,retain)UIImageView *hook_drop_one;
@property (nonatomic,retain)NSMutableArray *hook_drop_aone;
@property (nonatomic,retain)UIImageView *hook_swing_one;
@property (nonatomic,retain)NSMutableArray *hook_swing_aone;


@end

Now I understand why both animations are running at the same time when the app loads. I need to figure out how to trigger one animation after the first one stops, or set a delay for the second animation.

Anyone got any ideas?


You can using

 [CATransaction setCompletionBlock:^{ ... }]

please review session 421 WWDC 2011 - there is all info in second part of session.


Use i for determining the timming for your next animation , or you can start animation by touch event.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号