美文网首页
APP倒计时启动海报/启动广告

APP倒计时启动海报/启动广告

作者: 没错就是豪哥灬 | 来源:发表于2022-04-29 16:17 被阅读0次

    1.appdelegate里面 设置window.rootVC为需要显示的海报/广告vc

    LaunchADVC * vc = [[LaunchADVC alloc] init];

    BaseNavigationController *vcNav = [[BaseNavigationController alloc] initWithRootViewController:vc];

    self.window.rootViewController = vcNav;

    2.launchADVC里画一个imageview

    _adIV = [UIImageView new];

        _adIV.contentMode = UIViewContentModeScaleAspectFill;

        _adIV.clipsToBounds = YES;

    2.1可以海报未加载出来时,先显示LaunchScreen里的图片,这样就可以使启动图与海报无缝衔接.

    _placeholderIV = [UIImageView new];

        _placeholderIV.contentMode = UIViewContentModeScaleAspectFill;

        _placeholderIV.image = [self getLaunchScreenImg];

        [self.containerView addSubview:self.placeholderIV];

        [self.placeholderIV mas_makeConstraints:^(MASConstraintMaker *make) {

            make.top.left.right.bottom.mas_equalTo(self.containerView).offset(0);

        }];

    -(UIImage *)getLaunchScreenImg

    {

        UIViewController * vc = [[UIStoryboard storyboardWithName:@"LaunchScreen" bundle:[NSBundle mainBundle]] instantiateInitialViewController];

        CGRect rect = [UIScreen mainScreen].bounds;

        UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0f);

        CGContextRef context = UIGraphicsGetCurrentContext();

        vc.view.frame= rect;

        [vc.view.layer renderInContext:context];

        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

        UIGraphicsEndImageContext();

        return image;

    }

    [self.adIVsd_setImageWithURL:[NSURLURLWithString:resultDict[@"image_url"]]completed:^(UIImage*_Nullableimage,NSError*_Nullableerror,SDImageCacheTypecacheType,NSURL*_NullableimageURL)

                     {

                        self.placeholderIV.hidden=YES;

                        [self->_timerBtnstartTimer:5countDownBlock:^(boolisEnd) {

                            if(isEnd)

                            {

                                [selftimerBtnClick];

                            }

                        }];

                    }];

    3.后端设置上传的图片尺寸为1240*2208   ,要求设计图片的时候安全区域居中且尺寸为1100*2000(改尺寸并固定,可增宽增高) ,图片上需要显示的内容不要超出安全区域,不然有被裁剪掉的风险.

    相关文章

      网友评论

          本文标题:APP倒计时启动海报/启动广告

          本文链接:https://www.haomeiwen.com/subject/ezpsyrtx.html