話不多說直接上代碼:
在AppDelegate.m中
@interface AppDelegate ()<WXApiDelegate>
{
UIView *launchView;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//設(shè)置rootViewController的代碼
[self configLaunchImage];
return YES;
}
- (void)configLaunchImage {
UIViewController *vc = [[UIStoryboard storyboardWithName:@"LaunchScreen" bundle:[NSBundle mainBundle]] instantiateInitialViewController];
launchView = vc.view;
UIWindow *mainWindow = [UIApplication sharedApplication].keyWindow;
launchView.frame = [UIApplication sharedApplication].keyWindow.frame;
[mainWindow addSubview:launchView];
UIImageView *imageView=[[UIImageView alloc]init];
[imageView sd_setImageWithURL:[NSURL URLWithString:@"http://pic15.nipic.com/20110628/1369025_192645024000_2.jpg"]];
//根據(jù)需求添加約束最好
imageView.frame = CGRectMake(0, 0, mainWidthWJ, mainHeightWJ);
imageView.backgroundColor=[UIColor whiteColor];
[launchView addSubview:imageView];
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(removeLaunchImage) userInfo:nil repeats:NO];
}
-(void)removeLaunchImage
{
[launchView removeFromSuperview];
//設(shè)置rootViewController的代碼
}
接下來在LaunchScreen.storyboard設(shè)置下identifier 如圖所示

屏幕快照 2019-03-28 15.11.27.png
OK大功告成!!!!