2011-11-12 57 views
1

如何在應用程序委託類中設置動畫?如何在iPhone上設置動畫啓動?

+1

請詳細說明您的問題 – Maulik

+0

什麼是如此模糊和不清楚?我只是想添加一個像「TransitionFlipFromLeft」這樣的動畫轉換,當應用程序從啓動時出現時 – Nikita

回答

9

是的,您可以在加載應用程序後立即顯示動畫。

如果你想你的動畫 「爲Default.png」 淡出例如,當你的應用程序中加載,試試這個:

AppNameAppDelegate.h

#import UIKit/UIKit.h 

@interface AppNameAppDelegate : NSObject { 
    UIImageView *splashView; 
} 

@property (nonatomic, retain) IBOutlet UIWindow *window; 

- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context; 

@end 

AppNameAppDelegate。 m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    // Override point for customization after application launch. 
    [self.window makeKeyAndVisible]; 

    splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)]; 
    splashView.image = [UIImage imageNamed:@"Default.png"]; 
    [_window addSubview:splashView]; 
    [_window bringSubviewToFront:splashView]; 
    //Set your animation below 
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration:0.5]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:_window cache:YES]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector (startupAnimationDone:finished:context:)]; 
    splashView.frame = CGRectMake(-60, -60, 440, 600); 
    splashView.alpha = 0.0; 
    [UIView commitAnimations]; 

    return YES; 
} 

- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { 
    [splashView removeFromSuperview]; 
    [splashView release]; 
} 

我不確定這是你在找什麼,但也許...

+0

謝謝,這很有用 – Nikita

+0

@nik歡迎您;) – anasaitali

0

嗯... 我認爲你必須要更清楚一點。 您無法將動畫設置爲應用程序的絕對第一點。 您可以添加名爲「Default.png」的圖像,該圖像將在應用程序加載時顯示。

在AppDelegate中顯示動畫應該沒有什麼大問題,但它只會在您的應用程序加載後才顯示。

+0

什麼是如此模糊和不清楚?我只是想添加一個像「TransitionFlipFromLeft」這樣的動畫轉換,當應用程序從啓動時出現時 – Nikita

相關問題