iOS 實(shí)現(xiàn)動(dòng)態(tài)展示LaunchScreen閃屏頁

話不多說直接上代碼:

在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大功告成!!!!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容