我希望在默认图像消失后,在我的应用中插入一个启动动画。在我的应用程序中,我有一个导航栏和一个标签栏,所以我试图把它放在视图中加载:
UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myIMG.png"]];
[self.view addSubview:img];
然后,我希望通过转换为该图像设置动画,但是我将图像定位在视图中,在标签栏和导航栏之间,我希望所有图像前面的图像都能启动动画。我怎么能这样做?
答案 0 :(得分:2)
你应该:
[编辑]
如果您只想让imageView覆盖所有屏幕,那么您可以执行以下操作:
[appDelegate.window addSubview:imageView];
答案 1 :(得分:2)
在AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
....
....
....
frontScreen *animScreen = [[frontScreen alloc] initWithNibName:@"frontScreen" bundle:nil];
self.window.rootViewController = animScreen;
[self.window makeKeyAndVisible];
}
在frontScreen.m
AppDelegate* app =(AppDelegate*)[UIApplication sharedApplication].delegate;
[app afterAnimation];
在AppDelegate.m
-(void)afterAnimation {
rootController *list=[[rootController alloc] initWithNibName:@"rootController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:list];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible]; //optional
}
答案 2 :(得分:2)
//Display an Ads Imageview with animation on top of View
imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sale2.jpg"]];
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDetected:)];
tapGesture.numberOfTapsRequired = 1;
tapGesture.numberOfTouchesRequired = 1;
[imageView addGestureRecognizer:tapGesture];
[imageView setUserInteractionEnabled:YES];
[imageView setMultipleTouchEnabled:YES];
[UIView animateWithDuration:3.5 animations:^{imageView.alpha = 0;imageView.alpha = 1;}];
[self.window addSubview:imageView];
-(void)tapDetected:(UIGestureRecognizer*)recognizer{
//**************Remove the Advertising Image after the user press single tap on the img
[UIView animateWithDuration:1 animations:^{imageView.alpha = 1;imageView.alpha = 0;}];
}
答案 3 :(得分:0)
你最好的选择是创建一个Modal风格的segue,并用动画图像填充segue的视图,并在应用程序启动时,以编程方式立即调用segue,这是第一个出现
答案 4 :(得分:0)
[self.tabBarController.view addSubview:img];
然后您的图片将全屏显示。