Piero
Piero

Reputation: 9273

iOS app startup animation

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

Answers (5)

kky
kky

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

Son Nguyen
Son Nguyen

Reputation: 3491

You should:

  1. Create a view controller named startup view controller.
  2. In AppDelegate when app start, set this view is rootViewController
  3. Do some animation with your image or whatever you want while loading data or connecting to server.
  4. When everything done, from this start up view controller, you can remove this start up view and show your main view by call app delegate to set your main view controller is root view controller.

[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

saturngod
saturngod

Reputation: 24949

  1. Create View Controller for your startup animation
  2. In App Delegate , show your startup View Controller

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];
}
  1. After finished animation, call show tabview controller

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

Dzy
Dzy

Reputation: 153

[self.tabBarController.view addSubview:img];

then your image will show full screen.

Upvotes: 0

Alex Gosselin
Alex Gosselin

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

Related Questions