Git Product home page Git Product logo

yisplashscreen's Introduction

YISplashScreen 1.2.1

Easy splash screen + animation maker for iOS5+ (including iOS7).

ScreenShot1

  • YISplashScreen creates another UIWindow on top of status-bar so that transition will be nicer, compared to adding splash image directly on mainWindow.rootViewController.view.
  • animationBlock is used to hide splash image with two arguments:
    • splashLayer: splash image layer
    • rootLayer: copy of mainWindow.rootViewController.view.layer

View hierarchy before animation

  • mainWindow (not visible)
    • mainWindow.rootViewController.view
  • splashWindow
    • splashWindow.rootViewController.view (rotateable)
      • rootLayer (copy of mainWindow.rootViewController.view)
      • splashLayer (splash image layer)

Install via CocoaPods

pod 'YISplashScreen'

How to use

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // show splash
    [YISplashScreen show];
    
    // simple fade out
    [YISplashScreen hide];
    
    return YES;
}

Hiding Animations

// simple fade out
[YISplashScreen hide];

// cube
[YISplashScreen hideWithAnimation:[YISplashScreenAnimation cubeAnimation]];

// manually add animation
[YISplashScreen hideWithAnimationBlock:^(CALayer* splashLayer, CALayer* rootLayer) {
    
    // splashLayer moves up
    [CATransaction begin];
    [CATransaction setAnimationDuration:0.7];
    [CATransaction setAnimationTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
    
    splashLayer.position = CGPointMake(splashLayer.position.x, splashLayer.position.y-splashLayer.bounds.size.height);
    
    [CATransaction commit];
    
}];

CoreData Migration

By using [YISplashScreen showAndWaitForMigration:completion:] (optional), you can easily integrate simple UIAlertView-confirmation UI.

[YISplashScreen showAndWaitForMigration:^{
    
    //
    // NOTE: add CoreData migration logic here
    //
    
    NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                             [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
                             [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
    
    [persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
                                             configuration:nil
                                                       URL:url
                                                   options:options
                                                     error:nil];

} completion:^{
    
    [YISplashScreen hide];
    
}];

License

YISplashScreen is available under the Beerware license.

If we meet some day, and you think this stuff is worth it, you can buy me a beer in return.

yisplashscreen's People

Contributors

inamiy avatar martin-woolstenhulme avatar paulz avatar yberdnikov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yisplashscreen's Issues

ARC

Can I use with ARC project?

Solution to new iPhone Screen Sizes

Thanks for the great API. The following code should work with any screen size, until Apple substantively changes this portion of the API where UILaunchImages doesn't work anymore. That said, this method could fallback to your existing code in such a case, as it does in my subclass. :

@implementation YIPSplashScreen {}
+ (UIImage*)_preferredSplashImage
{
    NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
    CGSize screenSize = [[UIScreen mainScreen] bounds].size;
    NSString* viewOrientation = @"Portrait";

    if(!IS_PORTRAIT) {
        viewOrientation = @"Landscape";
        screenSize = CGSizeMake(screenSize.height,screenSize.width);
    }

    for (NSDictionary* dict in imagesDict) {
        // Can't find iPhone 6 HD using old method, however below technique seems to work well.
        // http://stackoverflow.com/questions/19107543/xcode-5-asset-catalog-how-to-reference-the-launchimage
        CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
        if (CGSizeEqualToSize(imageSize, screenSize) &&
                [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]]) {
            return [UIImage imageNamed:dict[@"UILaunchImageName"]];
        }
    }


   return nil; // or you can just keep former code below here, though it will unlikely ever be called.
}
@end

Not showing view from storyboard

Hi,

I call [YISplashScreen show] in didFinishLaunchingWithOptions but don't call [YISplashScreen hide] until my UIWebView has loaded - which my ViewController finds out about later.

Except that my ViewController (created via a storyboard) doesn't load. Looking at your code, it seems that your fix for the following issue:

#4

... has caused this.

If I put the call to [YISplashScreen hide] after [YISplashScreen show] in didFinishLaunchingWithOptions then my view controller loads. But I need my hide to be under programmatic control as indicated.

Thanks,

Tim

"Application windows are expected to have a root view controller at the end of application launch"

Hiya. I've tried using your default example with a storyboard project using the code:

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // show splash
    [YISplashScreen show];

    // simple fade out
    [YISplashScreen hide];

    return YES;
    }

.. on iOS 5.1.1 and iOS 6.0 I don't get the splash screen fade effect and the console logs out:

"Application windows are expected to have a root view controller at the end of application launch"

Any ideas?

EDIT: If I remove the two YISplashScreen lines I no longer get this message.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.