设置启动页图

本文介绍了一种在iOS应用中实现启动图的方法。通过在AppDelegate的didFinishLaunchingWithOptions方法中加载LaunchScreenStoryboard,并显示一个自定义的UIView来作为启动页。同时介绍了如何添加UIImageView来展示启动图片,以及如何设置定时器在指定时间后移除启动页。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    若想简单的实现添加一张网络的启动图或者动态的启动图可使用改方法:

    在appdelegate中的didFinishLaunchingWithOptions方法中写:

//启动页
@property (strong, nonatomic) UIView *ADView;
@property (strong, nonatomic) UIImageView *imageV;

{

    [self.window makeKeyAndVisible];

    UIStoryboard *launchStoryboard = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil];
    UIViewController *vc = (UIViewController *)[launchStoryboard instantiateViewControllerWithIdentifier:@"LaunchScreen"];
    
    self.ADView = (UIView *)vc.view;
    
    self.ADView.frame = CGRectMake(0, 0, UISCREEN.width, UISCREEN.height);
    [self.window addSubview:self.ADView];
    

    self.imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, UISCREEN.width, UISCREEN.height)];

    //若不图片的地址是动态的,则还需进行网络请求,但在    didFinishLaunchingWithOptions方法中不宜使用线程下载网络资源.

   NSString *str2 = @"http://img.itc.cn/photo/odVUMldO6Oj"; 
    
    [self.ADView addSubview:self.imageV];
    
    [self.window bringSubviewToFront:self.ADView];

    [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(removeADView) userInfo:nil repeats:NO];


 return YES;


}

    在removeADView该方法中移除添加的view


     这只是实现简单的需求,若复杂的需求还需在启动是创建VC,在VC中添加所要实现的功能


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值