在应用程序启动时加载可以从网络更新的图片

时间:2012-06-22 15:27:15

标签: iphone ios

我想在启动iPhone应用程序时启动一张图片(如启动画面)。但是如果这张照片发生变化,我想在互联网上检查一个特定的xml。如果图片不一样,我想在本地下载,以免每次下载。 你知道我怎么做吗?你有一个很好的教程吗?

由于

劳伦

1 个答案:

答案 0 :(得分:0)

当您知道自己在做什么时,启动画面动画非常酷。不幸的是,除了iPod(以及我怀疑的日历和消息)应用程序之外,无法更改应用程序的启动画面。所以...作弊。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
        //inits and windows and such

        // Make this interesting.
        _splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)];
        //make Default.png some boring white or grey color
        _splashView.image = [UIImage imageNamed:@"Default.png"];

        coloredSplashView_ = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)];
        coloredSplashView_.image = [UIImage imageNamed:@"colored_splash.png"];
        [coloredSplashView_ setAlpha:0.0f];

        [_window addSubview:_splashView];
        [_window addSubview:coloredSplashView_];
        [_window bringSubviewToFront:coloredSplashView_];

        [UIView animateWithDuration:1.00 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^{
            coloredSplashView_.alpha = 1.0;
            //make the splash visible
        }completion:^(BOOL finished) {
            //my personal touch: make it expand and fade out
            [_splashView removeFromSuperview];
            [UIView animateWithDuration:1.00 animations:^{
                [coloredSplashView_ setTransform:CGAffineTransformMakeScale(1.2, 1.2)];
                [coloredSplashView_ setAlpha:0.0f];
            }completion:^(BOOL finished){
                [coloredSplashView_ removeFromSuperview];
            }];
        }];    

    return YES;
}