Gabriel
Gabriel

Reputation: 328

iOS 5 Splash Page Transition

My client wants his splash image to fade out and then show the UI. I am not sure how to do this. As of right now it just appears once it loads. Is there a simple way to do this ?

Upvotes: 1

Views: 1810

Answers (4)

mhunturk
mhunturk

Reputation: 296

UIImageView *splash=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"splash"]];
[UIView animateWithDuration:1
                 animations:^{
                     splash.alpha = 0.0;
                 }
                 completion:^(BOOL finished)
 {
     [splash release];
 }]; 

Upvotes: 3

demon9733
demon9733

Reputation: 854

You can implement your own UIViewController as a splash screen:

@interface SplashScreenViewController : UIViewController {
    UIImageView *splashView;
}

@end

//

#import "SplashScreenViewController.h"

@implementation SplashScreenViewController

#pragma mark - View lifecycle

- (void)loadView {
    self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];

    splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    [splashView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
    [self.view addSubview:splashView];
}
- (void)viewWillAppear:(BOOL)animated {
    if (isIPad) {
        if (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]))
            splashView.image = [UIImage imageNamed:@"Default-Portrait~ipad.png"];
        else
            splashView.image = [UIImage imageNamed:@"Default-Landscape~ipad.png"];
    }
    else
        splashView.image = [UIImage imageNamed:@"Default.png"];
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    if (isIPad) {
        if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation))
            splashView.image = [UIImage imageNamed:@"Default-Portrait~ipad.png"];
        else
            splashView.image = [UIImage imageNamed:@"Default-Landscape~ipad.png"];
    }
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (isIPad ? YES : UIInterfaceOrientationIsPortrait(interfaceOrientation));
}

@end

Then, after showing, you can hide this UIViewController with any transition you want.

Upvotes: 1

Conrad Shultz
Conrad Shultz

Reputation: 8808

As I just explained on a closely related question, don't use splash screens! Please relate this to your client, who might not be familiar with the Human Interface Guidelines.

That said, if you can't convince you client otherwise, you can just fade out the UIImageView that I mentioned in my other response.

Upvotes: 1

atrljoe
atrljoe

Reputation: 8151

I was looking at this tutorial but decided not to implement it so I cant vouch as to whether it works or not but everything looks in check

http://www.dobervich.com/2010/10/22/fade-out-default-ipad-app-image-with-proper-orientation/

Beware though adding to much to your app startup is grounds for app rejection.

Avoid displaying an About window or a splash screen. In general, try to avoid providing any type of startup experience that prevents people from using your application immediately.

Source: Apple Developer Site

Upvotes: 1

Related Questions