美文网首页iOS点点滴滴
程序启动图延时消失

程序启动图延时消失

作者: xiao小马哥 | 来源:发表于2016-07-08 14:45 被阅读139次
90_104935_6.jpg

在程序启动的时候加一个动画!(如果你的代码是直接在appdelegate 中写的,直接粘贴过去就OK了,如果你单独做了一个启动图,那一样把这段代码粘贴过去,只需要把window换成view就Ok了!!)

CGSize viewSize = self.window.bounds.size;
NSString *viewOrientation = @"Portrait";    //横屏请设置成 @"Landscape"
NSString *launchImage = nil;

NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
for (NSDictionary* dict in imagesDict)
{
    CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
    
    if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]])
    {
        launchImage = dict[@"UILaunchImageName"];
    }
}

UIImageView *launchView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:launchImage]];
launchView.frame = self.window.bounds;
launchView.contentMode = UIViewContentModeScaleAspectFill;
[self.window addSubview:launchView];

[UIView animateWithDuration:2.0f
                      delay:0.0f
                    options:UIViewAnimationOptionBeginFromCurrentState
                 animations:^{
                     
                     launchView.alpha = 0.8f;
                     launchView.layer.transform = CATransform3DScale(CATransform3DIdentity, 1.2, 1.2, 1);
                     
                 }
                 completion:^(BOOL finished) {
                     
                     [launchView removeFromSuperview];
                
                 }];

相关文章

网友评论

    本文标题:程序启动图延时消失

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