美文网首页笔记
iOS获取启动图名字,在适当的位置做一些动画

iOS获取启动图名字,在适当的位置做一些动画

作者: Raybon_lee | 来源:发表于2016-01-20 16:56 被阅读538次

    获取我们添加到Assets.xcassets的LaunchImage

    配置启动图片如下所示

    launchimage

    获取这里面图片的名字做一些操作,我们代码如下

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.
       self.window =  [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
        CGSize viewSize  = self.window.bounds.size;
        
        NSLog(@"nrect = %@",NSStringFromCGRect(self.window.bounds));
        
        NSString * viewOrientation = @"Portrait";
        NSString * launchImage = nil;
        NSArray * imageDict = [[[NSBundle mainBundle] infoDictionary]valueForKey:@"UILaunchImages"];
        for (NSDictionary  * dict in imageDict) {
            CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
            if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]]) {
                launchImage = dict[@"UILaunchImageName"];
                
            }
        }
        NSLog(@"==luanch = %@",launchImage);
        
        UIImageView * luanchView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:launchImage]];
        self.window.backgroundColor = [UIColor whiteColor];
        luanchView.frame = self.window.bounds;
        luanchView.contentMode = UIViewContentModeScaleAspectFill;
        [self.window addSubview:luanchView];
        [UIView animateWithDuration:2.0f delay:1.0f usingSpringWithDamping:0.5f initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveLinear animations:^{
            luanchView.alpha = 0.0f;
            luanchView.layer.transform = CATransform3DScale(CATransform3DIdentity, 0.8, 0.8, 1);
            
        } completion:^(BOOL finished) {
            luanchView.layer.transform = CATransform3DIdentity;
            [luanchView removeFromSuperview];
        }];
        self.window.rootViewController = [UIViewController new];
        
        [self.window makeKeyWindow];
        
        
        return YES;
    }
    
    

    代码不多,就不用测试demo了,可以直接用代码测试一下,用到了就记录一下,大神还有更好的方法可以给我留言

    相关文章

      网友评论

        本文标题:iOS获取启动图名字,在适当的位置做一些动画

        本文链接:https://www.haomeiwen.com/subject/ksdlkttx.html