tranvutuan
tranvutuan

Reputation: 6109

animation in iphone

I am looking for some reference about the animation such that when you click on the application, it will bring you the first screen but slowly.

Does anybody know what it is please advice me on this issue. Thanks

edit I just wanna make a nice transition after all.Whenever I click on the application, the first screen just come up. I would like to make it nicer just like the first screen is brought slowly slowly and displayed on the scree. Hope it makes sense now.

Upvotes: 0

Views: 141

Answers (3)

Hampus Nilsson
Hampus Nilsson

Reputation: 6832

I assume you mean fading out the splash screen after the application starts? You can add something like this to applicationDidFinishLaunching to display the splash art full-screen immediately on boot, and then fade it out

UIView *topView = self.window.rootViewController.view;
bootSplashView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
bootSplashView.image = [UIImage imageNamed:@"iPhoneDefault.png"];
[topView addSubview:bootSplashView];
[self performSelector:@selector(fadeBootScreen) withObject:nil afterDelay:0];

And then in a separate method:

- (void)fadeBootScreen
{
    [UIView animateWithDuration:0.4 delay:0.0 options:UIViewAnimationCurveEaseIn animations:^{
        bootSplashView.alpha = 0.0;
    } completion:^(BOOL finished) {
        [bootSplashView removeFromSuperview];
        bootSplashView = nil;
    }];
}

Make sure to add 'bootSplashView' as an class variable. If your app can start in different orientation (relevant on the iPad), specialize for those cases by loading a different image.

Upvotes: 1

Thyraz
Thyraz

Reputation: 2432

UIView has a lot methods for animating them. Take a look at the View Programming Guide:

http://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/AnimatingViews/AnimatingViews.html#//apple_ref/doc/uid/TP40009503-CH6-SW1

The UIView documentation also has a chapter that lists the animation related methods: http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/UIView/UIView.html#//apple_ref/doc/uid/TP40006816-CH3-SW131

And here's an example for a block based animation, which will fade in a view using it's alpha value:

NSTimeInterval animationDuration = 0.3;
CGFloat startValue = 0.0;
CGFloat endValue = 1.0;

myView.alpha = startValue;

[UIView animateWithDuration:animationDuration delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
                myView.alpha = endValue
    }
                     completion:^(BOOL finished){
                          // If you need to do something additional once the animation is finished, place it here.
                     }];

Upvotes: 1

Rodrigo Camargo
Rodrigo Camargo

Reputation: 180

Well, this is a broad question, but I think you can try Cocos2D for this. There are a lot of examples how to use it, but one simple animation example is this: http://www.raywenderlich.com/1271/how-to-use-animations-and-sprite-sheets-in-cocos2d

Also, there is a good book called "Learning Cocos2D" where there is a good example of managing menus and load layers. http://cocos2dbook.com/

I hope I could help.

Upvotes: 1

Related Questions