iOS - 自定義啓動圖

自定義啓動圖有不少方法, 原理都差很少, 系統的LaunchImage是不能修改的, 因此能夠用它當作底圖, 而後再往這個圖上加本身的需求服務器

//在AppDelegate聲明啓動圖 customLaunchImageView
//在didFinishLaunchingWithOptions 調用[self setUpLaunchScreen]
//注意:self.window的rootViewController已設置//添加啓動圖
- (void)setUpLaunchScreen {
    self.customLaunchImageView = [[UIImageView alloc]initWithFrame:self.window.bounds];
    self.customLaunchImageView.userInteractionEnabled = YES;
    self.customLaunchImageView.image = [UIImage imageNamed:@"這個圖片需和LaunchImage圖片如出一轍, 要判斷尺寸"];        //自定義控件我就略了
    [self.customLaunchImageView addSubview: yourLabel];
    [self.customLaunchImageView addSubview: yourImageView];
    [yourImageView setImageWithURL:[NSURL URLWithString:@"圖片地址填寫服務器返回的地址"]                  placeholderImage:[UIImage imageNamed:@"佔位圖能夠不寫"]];
    [yourButton addTarget:self action:@selector(yourButtonClick) forControlEvents:UIControlEventTouchDown];
    [self.customLaunchImageView addSubview:yourButton];
    [self.window addSubview:self.customLaunchImageView];
    [self.window bringSubviewToFront:self.customLaunchImageView];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5*NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self yourButtonClick];
    });
}
- (void)yourButtonClick {        //是否顯示新版本引導頁加在這裏        //移動自定義啓動圖
    if (self.customLaunchImageView) {        [UIView animateWithDuration:0.3 animations:^{            self.customLaunchImageView.alpha = 0;
    } completion:^(BOOL finished) {
        [self.customLaunchImageView removeFromSuperview];
        self.customLaunchImageView = nil;
    }];
    }}
相關文章
相關標籤/搜索