在application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 这个方法里面写,一般放在最后
NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)firstObject]; //拼接文件名 NSString *detailPath = [docPath stringByAppendingPathComponent:@"launchScreen.png"]; NSFileManager *manager = [NSFileManager defaultManager]; BOOL exist = [manager fileExistsAtPath:detailPath]; if (exist) { NSLog(@"%@",@"启动图片存在"); UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.window.frame.size.width, self.window.frame.size.height)]; imageView.image = [UIImage imageWithContentsOfFile:detailPath]; [self.window addSubview:imageView]; [UIView animateWithDuration:1 delay:1 options:0 animations:^{ imageView.alpha = 0; //加特效 //imageView.layer.transform = CATransform3DScale(CATransform3DIdentity, 1.5, 1.5, 1); } completion:^(BOOL finished) { [imageView removeFromSuperview]; }]; } else { NSLog(@"%@",@"启动图不存在,重新下载"); dispatch_async(dispatch_get_global_queue(0, 0), ^{ NSString *url = @"http://img.taopic.com/uploads/allimg/110812/1820-110Q20I63022.jpg"; NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]]; UIImage *image = [UIImage imageWithData:data]; //保存图片到Document [UIImagePNGRepresentation(image) writeToFile:detailPath atomically:YES]; }); }