Reputation: 9273
I want to insert in my app a startup animation, after the default image disappears. In my app, I have a navigation bar and a tab bar, so I have tried to put this in the view did load:
UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myIMG.png"]];
[self.view addSubview:img];
Then, I want to animate that image with a transition, but with the image I positioned in the view, between the tab bar and the nav bar, and I want the the image in front of all to start the animation. How can I do this?
Upvotes: 0
Views: 3937
Reputation: 21
//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;}];
}
Upvotes: 2
Reputation: 3491
You should:
[Edit]
In case you only want the imageView can cover all the screen, then you can do as following:
[appDelegate.window addSubview:imageView];
Upvotes: 2
Reputation: 24949
In AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
....
....
....
frontScreen *animScreen = [[frontScreen alloc] initWithNibName:@"frontScreen" bundle:nil];
self.window.rootViewController = animScreen;
[self.window makeKeyAndVisible];
}
In frontScreen.m
AppDelegate* app =(AppDelegate*)[UIApplication sharedApplication].delegate;
[app afterAnimation];
In 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
}
Upvotes: 2
Reputation: 153
[self.tabBarController.view addSubview:img];
then your image will show full screen.
Upvotes: 0
Reputation: 2930
Your best bet to cover everything is to create a segue of the Modal style, and fill that segue's view with your animation image, and as the app launches, programmatically call that segue right away, so it is the first thing to appear.
Upvotes: 0