如何在app delegate类中设置动画?
答案 0 :(得分: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];
}
我不确定这是你在找什么,但也许......
答案 1 :(得分:0)
嗯... 我想你必须更清楚一点。 您无法将动画设置为应用程序的绝对第一点。 您可以添加一个名为“Default.png”的图像,该图像将在您加载应用程序时显示。
在AppDelegate中显示动画应该没有任何重大问题,但只会在你的应用程序加载后显示。