Git Product home page Git Product logo

allluckly / lblaunchimagead Goto Github PK

View Code? Open in Web Editor NEW
578.0 19.0 107.0 8.86 MB

iOS开发轻量级启动广告,动态获取网络启动图片,具有渐变的启动动画,支持半屏和全屏,类似百度ssp广告和广点通的广告。支持广告点击等,集成非常的方便。欢迎使用,好用请star

Home Page: http://allluckly.cn/

License: MIT License

Objective-C 95.16% Ruby 4.84%
ios

lblaunchimagead's Introduction

LBLaunchImageAd

Apps Using Codewake Carthage compatible Pod Platform Pod Version Pod License

支持pod导入

pod 'LBLaunchImageAd','~> 1.1.3'

如果发现pod search LBLaunchImageAd 搜索出来的不是最新版本,需要在终端执行cd转换文件路径命令退回到desktop,然后执行pod setup命令更新本地spec缓存(可能需要几分钟),然后再搜索就可以了;也可以试下如下方法

rm ~/Library/Caches/CocoaPods/search_index.json

然后再pod search LBLaunchImageAd

本框架将用在涂嗨oh上线项目中,到时有兴趣的朋友可以下载看看效果

2021/02/2号更新:

1.1.3

SDWebImage/Core (5.9.5)

SceneDelegate 无法找到 keyWindow 的 bug

2020/04/10号更新:

1.1.2 删除UIWebView,升级SDWebImage为5.7.1版本

2020/03/03号更新:

1.1.1 LaunchScreen.storyboard和LaunchImage无痕切换;如果需要把LaunchImage换成LaunchScreen.storyboard只需要删除LaunchImage然后创建LaunchScreen.storyboard然后到项目中的TARGETS --> APP Icons and Launch Images 修改LaunchScreen File 为LaunchScreen即可

2018/10/21号更新:

1.0.9 适配iPhone XS+++

2018/9/08号更新:

1.0.8修复一些bug~

2018/2/02号更新:

1.0.6增加缓存,如果已经加载过启动图片,那么在没有网络的情况下也会加载,更新后台图片时,第一次加载的是原来已有的图片,下一次加载就是最新的图片了

2018/1/31号更新:

1.0.5修复网络gif图片只展示第一帧的bug,修复iPhone X 点击跳过无效的bug

2017/6/28号更新:

修复bug,修复cocopods版本不同步等问题

2017/4/1号更新:

1.优化封装调用接口

2.优化性能

ps:有什么问题可以留言,好用请star支持

技术交流群:534926022(0.8/人付费) 511040024(0.8/人付费)

iOS开发学习app下载

实现原理介绍

效果图如下:

(LBLaunchImageAd)

本框架依赖SDWebImage

导入#import "NSObject+LBLaunchImage.h"

AppDelegate.mdidFinishLaunchingWithOptions方法中复制如下代码即可

如果需要网络请求得到URL的例子如下

    //举个例子[LBNetWork PostAPI:url Dic:nil Suc:^(NSDictionary *Res)是自己封装的网络请求 
    [NSObject makeLBLaunchImageAdView:^(LBLaunchImageAdView *imgAdView) {
        //设置广告的类型
        imgAdView.getLBlaunchImageAdViewType(LogoAdType);
        //自定义跳过按钮
        imgAdView.skipBtn.backgroundColor = [UIColor lightGrayColor];
        imgAdView.skipBtn.alpha = 0.5;
        [imgAdView.skipBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        __block LBLaunchImageAdView *adView = imgAdView;
        imgAdView.clickBlock = ^(const clickType type) {
            switch (type) {
                case clickAdType:{
                    NSLog(@"点击广告回调");
                    if (adView.advertUrl.length > 10 && adView.isClickAdView) {
                        LBAdVC *vc = [[LBAdVC alloc]init];
                        vc.url = adView.advertUrl;
                        vc.view.backgroundColor = [UIColor whiteColor];
                        if (self.tabBarController) {
                            [self.window setRootViewController:self.tabBarController];
                        }else{
                            [self setupViewControllers];
                            [self.window setRootViewController:self.tabBarController];
                        }
                        CYLTabBarController *tab = (CYLTabBarController *)_window.rootViewController;
                        UINavigationController *nav = (UINavigationController *)tab.viewControllers[0];
                        vc.hidesBottomBarWhenPushed = YES;
                        [nav pushViewController:vc animated:YES];
                    }
                
                }
                break;
                case skipAdType:
                    NSLog(@"点击跳过回调");
                    if (self.tabBarController) {
                        [self.window setRootViewController:self.tabBarController];
                    }else{
                        [self setupViewControllers];
                        [self.window setRootViewController:self.tabBarController];
                    }
                
                
                break;
                case overtimeAdType:
                    NSLog(@"倒计时完成后的回调");
                    [self.window setRootViewController:self.tabBarController];
                break;
                default:
                break;
            }
        };
        ///网络请求
        [req startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        //        NSLog(@"%@",request.responseJSONObject);
            NSDictionary *dic = request.responseJSONObject;
            if (dic) {
                //设置网络启动图片URL
                imgAdView.imgUrl = dic[@"imgURl"];
                //点击响应的url
                imgAdView.advertUrl = dic[@"clickURl"];
                //是否能点击
                imgAdView.isClickAdView = [dic[@"isClick"] boolValue];
            }
        
        } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
        
        }];
       
       
  }];
       
    

如果直接是固定的图片Url

    __weak typeof(self) weakSelf = self;
    [NSObject makeLBLaunchImageAdView:^(LBLaunchImageAdView *imgAdView) {
        //设置广告的类型
        imgAdView.getLBlaunchImageAdViewType(LogoAdType);
        imgAdView.imgUrl = @"http://www.uisheji.com/wp-content/uploads/2013/04/19/app-design-uisheji-ui-icon20121_55.jpg";
        //自定义跳过按钮
        imgAdView.skipBtn.backgroundColor = [UIColor blackColor];
        //各种点击事件的回调
        imgAdView.clickBlock = ^(clickType type){
            switch (type) {
                case clickAdType:{
                    NSLog(@"点击广告回调");
                    TestViewController *vc = [[TestViewController alloc]init];
                    vc.view.backgroundColor = [UIColor whiteColor];
                    [weakSelf.window.rootViewController presentViewController:vc animated:YES completion:^{

                    }];
                }
                    break;
                case skipAdType:
                    NSLog(@"点击跳过回调");
                    break;
                case overtimeAdType:
                    NSLog(@"倒计时完成后的回调");
                    break;
                default:
                    break;
            }
        };
       
    }];

如果是本地图片


__weak typeof(self) weakSelf = self;
    [NSObject makeLBLaunchImageAdView:^(LBLaunchImageAdView *imgAdView) {
        //设置广告的类型
        imgAdView.getLBlaunchImageAdViewType(LogoAdType);
        //设置本地启动图片
        imgAdView.localAdImgName = @"qidong.gif";
        //自定义跳过按钮
        imgAdView.skipBtn.backgroundColor = [UIColor blackColor];
        //各种点击事件的回调
        imgAdView.clickBlock = ^(clickType type){
            switch (type) {
                case clickAdType:{
                    NSLog(@"点击广告回调");
                    TestViewController *vc = [[TestViewController alloc]init];
                    vc.view.backgroundColor = [UIColor whiteColor];
                    [weakSelf.window.rootViewController presentViewController:vc animated:YES completion:^{

                    }];
                }
                    break;
                case skipAdType:
                    NSLog(@"点击跳过回调");
                    break;
                case overtimeAdType:
                    NSLog(@"倒计时完成后的回调");
                    break;
                default:
                    break;
            }
        };
       
    }];

lblaunchimagead's People

Contributors

allluckly avatar sobison avatar wvqusrtg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lblaunchimagead's Issues

【提需求】

【需求单】
1、可以播放视频(本地 和 远程的);
https://github.com/CoderZhuXH/XHLaunchAd 这个框架就可以播放视频,只是作者没有维护,但是可以看到作者的前瞻性,这么久了只是iOS系统Api升级造成的。
2、时间模块(计时器),单独用一个工具类进行封装,不要和业务代码裹在一起;
这是我自己封装的Timer框架https://github.com/295060456/JobsTimer
可以适当参考

无法使用

我现在下载您的demo,运行之后只是一个设置在Brand Assets里面的图片显示,至于其他的倒计时跳过还有网络URL的图片都没有显示,这是怎么 回事呢

多张图怎么添加?

您好 我要添加多张图怎么弄? 没有找到添加多张图的API,能否提供多张图API谢谢!

关于内存的问题 求指教

此框架很好,简单易懂,可是发现一个问题:此demo在6plus真机上跑,运行此启动控件的话 内存大约为18M左右,然后不运行此启动控件的话 内存大约为4左右,这无缘无故多了十几M的内存,不知哪里出来的,看了你的代码有做removeFromSuperview释放,而且delloc方法也执行了,始终释放不掉这多余的十几M内存,求指教,详情请看我录的文件
未命名.mov.zip

Solution for the people who is using swift

    let vc = TestViewController()
    let adview = LBLaunchImageAdView.init(window: self.window, andType: 1, andImgUrl: "http://www.uisheji.com/wp-content/uploads/2013/04/19/app-design-uisheji-ui-icon20121_55.jpg")
    adview!.clickBlock = {(LBClick) in
        switch LBClick {
        case 1100:
            NSLog("jump to the ad link")
            vc.view.backgroundColor = UIColor.whiteColor()
            self.window?.rootViewController?.presentViewController(vc, animated: true, completion: nil)
            break
        case 1101:
            NSLog("drectly jump to the homescreen")
            break
        case 1102:
            NSLog("drectly jump to the homescreen")
            break
        default:
            break
        }
    }

I just figured it out. Hope it help~

最新版的有个问题

我看最新版 : 优化无法释放的问题 重新创建了一个控制器,并设置成了window的rootvc。但是这样一来,就会把我的原本跟控制器给替换掉。导致广告消失之后会显示空白页面...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.