iOS 7启动图像(启动画面)淡出 [英] iOS 7 launch image (splash screen) fades out

查看:157
本文介绍了iOS 7启动图像(启动画面)淡出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 7上,启动图像时淡出而不是在加载应用程序时立即消失。

On iOS 7, launch images fade out instead of disappearing immediately when the app is loaded.

是否有任何设置可以阻止此启动图像淡出动画?
我需要它立即消失,就像在iOS 6及更早版本中一样。

Is there any setting to prevent this launch image fade out animation? I need it to disappear immediately just like in the iOS 6 and earlier.

编辑答案:

是的,可以将启动图像作为UIImageView添加到顶部窗口,并在启动渐变渐变动画后隐藏它。但这会造成0.4秒的延迟,我正试图避免。

推荐答案

我设法做到了在AppController中。只需在创建glView后立即放置此代码

I have managed to do that in the AppController. Just place this code right after the creation of the glView

    UIImage* image = [UIImage imageNamed:[self getLaunchImageName]];
if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)])
{
    float screenScale = [[UIScreen mainScreen] scale];
    if (screenScale > 1.)
        image = [UIImage imageWithCGImage:image.CGImage scale:screenScale orientation:image.imageOrientation];
}
UIImageView *splashView = [[UIImageView alloc] initWithImage:image];
[viewController.view addSubview:splashView];
[splashView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.1f];

很容易。只需获取启动图像,并在延迟后使其消失。您将需要getLaunchImage代码(基于此评论,未经iPhone 6测试或6 +)

It is easy. Just get the launch image and make it disappear after a delay. You will need the getLaunchImage code (based on this comment, not tested with iPhone 6 nor 6 plus)

    -(NSString*)getLaunchImageName
{

    NSArray* images= @[@"LaunchImage.png",
                       @"LaunchImage@2x.png",
                       @"LaunchImage-700@2x.png",
                       @"LaunchImage-568h@2x.png",
                       @"LaunchImage-700-568h@2x.png",
                       @"LaunchImage-700-Portrait@2x~ipad.png",
                       @"LaunchImage-Portrait@2x~ipad.png",
                       @"LaunchImage-700-Portrait~ipad.png",
                       @"LaunchImage-Portrait~ipad.png",
                       @"LaunchImage-Landscape@2x~ipad.png",
                       @"LaunchImage-700-Landscape@2x~ipad.png",
                       @"LaunchImage-Landscape~ipad.png",
                       @"LaunchImage-700-Landscape~ipad.png",
                       @"LaunchImage-800-667h@2x.png",
                       @"LaunchImage-800-Portrait-736h@3x.png",
                       @"LaunchImage-800-Landscape-736h@3x.png",
                       ];

    UIImage *splashImage;

    if ([self isDeviceiPhone])
    {
        if ([self isDeviceiPhone4] && [self isDeviceRetina])
        {
            splashImage = [UIImage imageNamed:images[1]];
            if (splashImage.size.width!=0)
                return images[1];
            else
                return images[2];
        }
        else if ([self isDeviceiPhone5])
        {
            splashImage = [UIImage imageNamed:images[1]];
            if (splashImage.size.width!=0)
                return images[3];
            else
                return images[4];
        }
        else if ([self isDeviceiPhone6])
        {
            splashImage = [UIImage imageNamed:images[1]];
            if (splashImage.size.width!=0)
                return images[13];
            else
                return images[14];
        }
        else
            return images[0]; //Non-retina iPhone
    }
    else if ([[UIDevice currentDevice] orientation]==UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown)//iPad Portrait
    {
        if ([self isDeviceRetina])
        {
            splashImage = [UIImage imageNamed:images[5]];
            if (splashImage.size.width!=0)
                return images[5];
            else
                return images[6];
        }
        else
        {
            splashImage = [UIImage imageNamed:images[7]];
            if (splashImage.size.width!=0)
                return images[7];
            else
                return images[8];
        }

    }
    else
    {
        if ([self isDeviceRetina])
        {
            splashImage = [UIImage imageNamed:images[9]];
            if (splashImage.size.width!=0)
                return images[9];
            else
                return images[10];
        }
        else
        {
            splashImage = [UIImage imageNamed:images[11]];
            if (splashImage.size.width!=0)
                return images[11];
            else
                return images[12];
        }
    }
}

-(BOOL)isDeviceiPhone
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        return TRUE;
    }

    return FALSE;
}

-(BOOL)isDeviceiPhone4
{
    if ([[UIScreen mainScreen] bounds].size.height==480)
        return TRUE;

    return FALSE;
}


-(BOOL)isDeviceRetina
{
    if ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] &&
        ([UIScreen mainScreen].scale == 2.0))        // Retina display
    {
        return TRUE;
    }
    else                                          // non-Retina display
    {
        return FALSE;
    }
}


-(BOOL)isDeviceiPhone5
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && [[UIScreen mainScreen] bounds].size.height==568)
    {
        return TRUE;
    }
    return FALSE;
}

-(BOOL)isDeviceiPhone6
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && [[UIScreen mainScreen] bounds].size.height>568)
    {
        return TRUE;
    }
    return FALSE;
}

这篇关于iOS 7启动图像(启动画面)淡出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆