广告页

作者: 你好哈喽哈喽 | 来源:发表于2019-11-26 09:33 被阅读0次
  • (void)setUpLaunchScreen{

    NSURL *fileUrl;
    if (screen_width==480) {// 屏幕的高度为480
    fileUrl = [[NSBundle mainBundle] URLForResource:@"startup1" withExtension:@"gif"]; // 加载GIF图片
    }else if(screen_width==568) {// 屏幕的高度为568
    //5 5s 0.853333 0.851574
    fileUrl = [[NSBundle mainBundle] URLForResource:@"startup2" withExtension:@"gif"]; // 加载GIF图片

    }else if(screen_width==667){// 屏幕的高度为667
    //6 6s 7 1.000000 1.000000
    fileUrl = [[NSBundle mainBundle] URLForResource:@"startup3" withExtension:@"gif"]; // 加载GIF图片
    }else if(screen_width==736){// 屏幕的高度为736
    //6p 6sp 7p
    fileUrl = [[NSBundle mainBundle] URLForResource:@"startup4" withExtension:@"gif"]; // 加载GIF图片
    }else if(screen_width==812){// 屏幕的高度为812 375.000000 812.000000
    // x
    fileUrl = [[NSBundle mainBundle] URLForResource:@"startup5" withExtension:@"gif"]; // 加载GIF图片
    }else{

    }

    CGImageSourceRef gifSource = CGImageSourceCreateWithURL((CFURLRef) fileUrl, NULL); //将GIF图片转换成对应的图片源
    size_t frameCout = CGImageSourceGetCount(gifSource); // 获取其中图片源个数,即由多少帧图片组成
    NSMutableArray *frames = [[NSMutableArray alloc] init]; // 定义数组存储拆分出来的图片
    for (size_t i = 0; i < frameCout; i++) {
    CGImageRef imageRef = CGImageSourceCreateImageAtIndex(gifSource, i, NULL); // 从GIF图片中取出源图片
    UIImage *imageName = [UIImage imageWithCGImage:imageRef]; // 将图片源转换成UIimageView能使用的图片源
    [frames addObject:imageName]; // 将图片加入数组中
    CGImageRelease(imageRef);
    }

    self.launchImageView = [[UIImageView alloc]initWithFrame:self.window.bounds];
    NSLog(@"宽高为%lf %lf",self.window.bounds.size.width,self.window.bounds.size.height);
    self.launchImageView.userInteractionEnabled = YES;

    self.launchImageView.animationImages = frames; // 将图片数组加入UIImageView动画数组中
    self.launchImageView.animationDuration = 0.7; // 每次动画时长
    [self.launchImageView startAnimating]; // 开启动画,此处没有调用播放次数接口,UIImageView默认播放次数为无限次,故这里不做处理

    [[UIApplication sharedApplication].keyWindow addSubview:self.launchImageView];
    [[UIApplication sharedApplication].keyWindow bringSubviewToFront:self.launchImageView];

    //5秒后自动关闭
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5*NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [self yourButtonClick];
    });

}

  • (void)yourButtonClick {

    // 移动自定义启动图
    if (self.launchImageView) {
    [UIView animateWithDuration:0.3 animations:^{
    self.launchImageView.alpha = 0;
    } completion:^(BOOL finished) {
    [self.launchImageView removeFromSuperview];
    self.launchImageView = nil;
    }];
    }
    }

相关文章

  • 广告页

    (void)setUpLaunchScreen{NSURL *fileUrl;if (screen_width==...

  • oc自定义present,dismiss动画

    今天在写项目的广告页,之前是用uiview写的广告页,但是由于没办法在广告页出现的时候隐藏statusBar,无奈...

  • app开机广告

    无论是哪个app它的开机步骤大体相同,splash广告->引导页->首页(或登录页)。 广告页的图片加载时影响开机...

  • 关于启动页时间问题

    需求:启动页显示后显示请求的广告页,显示3.2.1数字倒数之后,跳转到首页。 问题1:直接设置广告页3秒后隐藏,造...

  • Xcode11设置广告页和launchImage设置启动页

    一、广告页设置 1.SceneDelegate设置window 2.开发一个广告页 3.在SceneDelegat...

  • 启动页+广告页实现优化

    前言 每个app中都有启动+广告这个功能逻辑,或多或少,每个公司的逻辑都不大一样,最近我优化了一版广告业+启动页面...

  • SwiftUI实战-广告页、欢迎页

    每次app首次打开,有时候会有广告位的需要或者展示欢迎页的功能效果图: 源码如下:LauchViewModel.s...

  • 启动加载广告页面

    转载自:http://ios.jobbole.com/85556/ 思路 1.广告页加载思路。广告页的内容要实时显...

  • iOS开发中的小技巧12:NSNotificationCente

    开发中会有一些操作是有紧密联系的,例如电商中广告页和首页的拉帘式广告,拉帘式广告是在广告页结束后才会出现的,而广告...

  • 新闻APP广告方式总结

    广告方式: ①横幅广告、通栏广告、广告条②公告③插屏④启动页广告⑤信息流广告【微信朋友圈,网易新闻】⑥积分广告【通...

网友评论

      本文标题:广告页

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