Giter Site home page Giter Site logo

xhlaunchad's Introduction

XHLaunchAd

  • 几行代码接入启动页广告功能.

效果

image

使用方法

1.设置项目启动页为LaunchImage

  • 1.设置方法:在Assets.xcassets中新建LaunchImage
    2.在项目TARGETS->General->App Icons and Launch Images中设置 Launch Images Source 为LaunchImage,并将Launch Screen File 设为空(如图)
    image

2.在LaunchImage 添加相应启动图片

  • 1.如图
    image

3.在AppDelegate中导入XHLaunchAd.h 头文件,在设置window.rootViewController之后调用下面方法

    //1.初始化启动页广告
    XHLaunchAd *launchAd = [[XHLaunchAd alloc] initWithFrame:CGRectMake(0, 0,self.window.bounds.size.width,  self.window.bounds.size.height-150) andDuration:3.5];
    
    //2.设置启动页广告图片的url(必须)
    //此处请进行数据请求,从服务器获取广告图片url
    NSString *imgUrlString =@"http://img.taopic.com/uploads/allimg/120906/219077-120Z616330677.jpg";
    [launchAd imgUrlString:imgUrlString completed:^(UIImage *image, NSURL *url) {
        //异步加载图片完成回调(若需根据图片实际尺寸,刷新广告frame,可在这里操作)
        //launchAd.adFrame = ...;
    }];
    
    //广告点击事件(可选)
    launchAd.clickBlock = ^()
    {
        NSString *url = @"https://www.baidu.com";
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
    };
    //3.添加至根控制器视图上
    [self.window.rootViewController.view addSubview:launchAd];

安装

手动添加:

  • 1.将 XHLaunchAd 文件夹添加到工程目录中
  • 2.导入 XHLaunchAd.h

CocoaPods:

  • 1.在 Podfile 中添加 pod 'XHLaunchAd'
  • 2.执行 pod install 或 pod update
  • 3.导入 XHLaunchAd.h

系统要求

  • 该项目最低支持 iOS 7.0 和 Xcode 7.0

许可证

XHLaunchAd 使用 MIT 许可证,详情见 LICENSE 文件

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.