引导页
包含文件
- AppDelegate.h, AppDelegate.m
实现功能
1、简单功能
- 设置App的底色为白色
- 加载主页面
- 隐藏navigationBarHidden, 设置状态栏的样色为UIStatusBarStyleLightContent
- 调用引导效果
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:kScreenBounds];
self.window.backgroundColor = [UIColor whiteColor];
。。。//加载主页面
[self.window makeKeyAndVisible];
navigationController.navigationBarHidden = YES;
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
[self setLauchView];
return YES;
}
2、引导效果(重点)
- 创建UIImageView(_launchImaViewT),大小为全屏
- 创建UIImageView(_launchImaViewO),大小为全屏,默认图片为Default@2x.png,_launchImaViewO遮盖_launchImaViewT
- 获取网络图片,如果成功,_launchImaViewT加载该图片,并用2秒动画效果显示,将_launchImaViewO设置为全透明
- 动画执行完毕后,移除_launchImaViewO,_launchImaViewT
@property(strong,nonatomic) UIImageView *launchImaViewO; @property(strong,nonatomic) UIImageView *launchImaViewT; - (void)setLauchView { _launchImaViewT = [[UIImageView alloc] initWithFrame:kScreenBounds]; _launchImaViewT.contentMode = UIViewContentModeScaleAspectFill; [self.window addSubview:_launchImaViewT]; _launchImaViewO = [[UIImageView alloc] initWithFrame:kScreenBounds]; _launchImaViewO.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default@2x" ofType:@"png"]]; [self.window addSubview:_launchImaViewO]; [HttpOperation getRequestWithURL:@"start-image/720*1184" parameters:nil success:^(id responseObject) { [_launchImaViewT sd_setImageWithURL:[NSURL URLWithString:responseObject[@"img"]]]; [UIView animateWithDuration:2.0f animations:^{ _launchImaViewO.alpha = 0.f; _launchImaViewT.transform = CGAffineTransformMakeScale(1.2, 1.2); } completion:^(BOOL finished) { [_launchImaViewO removeFromSuperview]; [_launchImaViewT removeFromSuperview]; }]; } failure:nil]; }
这里面有问题,如果获取图片失败(没有网络等),会一直阻塞在引导页面。
- 添加条件,如果获取失败,则使用_launchImaViewO进行动画效果
。。。 } failure:^(NSError *error) { [UIView animateWithDuration:2.0f animations:^{ _launchImaViewO.transform = CGAffineTransformMakeScale(1.2, 1.2); } completion:^(BOOL finished) { [_launchImaViewO removeFromSuperview]; [_launchImaViewT removeFromSuperview]; }]; }];