设置启动页图

来源:互联网 发布:机智交易软件 编辑:程序博客网 时间:2024/04/28 18:15

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

    在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中添加所要实现的功能


0 0