2

GitHub - MQZHot/ZLaunchAd: 快速集成启动广告,支持LaunchImage和LaunchScreen,支持GI...

 6 years ago
source link: https://github.com/MQZHot/ZLaunchAd
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

ZLaunchAd

image image image image

ZLaunchAd集成启动广告,支持LaunchImageLaunchScreen,支持GIF,支持本地图片,支持视图过渡动画

image image image image image image

功能

  • 支持进入前台广告显示,设定时间间隔,进入后台后返回的时间大于间隔才进行显示
  • 支持Objective-C/Swift
  • 自带图片缓存,清除缓存
  • 自定义跳过按钮外观、位置
  • 支持网络/本地资源,支持GIF图片显示
  • 支持LaunchImage和LaunchScreen.storyboard.
  • 支持广告点击事件,支持广告完成动画设置

使用

let adView = ZLaunchAd.create()
let imageResource = ZLaunchAdImageResourceConfigure()
imageResource.imageNameOrImageURL = "163yun"
imageResource.imageDuration = 5
imageResource.imageFrame = UIScreen.main.bounds
adView.setImageResource(imageResource, action: {
    /// 广告点击
})

创建广告View

/// 初始化方法,创建广告View
///
/// - Parameters:
///   - waitTime: 加载广告等待的时间,默认3s
///   - showEnterForeground: 是否进入前台时显示,默认`false`
///   - adNetRequest: 广告网络请求。如果需要每次进入前台是显示不同的广告图片,网络请求写在此闭包中
/// - Returns: ZLaunchAdView
func create(waitTime: Int = 3, showEnterForeground: Bool = false, adNetRequest: ((ZLaunchAdView)->())? = nil) -> ZLaunchAdView

配置图片资源----配置跳过按钮

/// 加载图片,网络图片/本地图片/GIF图片
///
/// - Parameters:
///   - imageResource: 配置图片资源
///   - buttonConfig:  配置跳过按钮
///   - action: 广告点击响应
func setImageResource(_ imageResource: ZLaunchAdImageResourceConfigure, buttonConfig: ZLaunchSkipButtonConfig? = nil, action: ZLaunchClosure?)

进入后台后返回的时间大于间隔才进行显示, 默认10s

var timeForWillEnterForeground: Double = 10

页面配置

  • ZLaunchSkipButtonConfig:跳过按钮配置
/// 按钮位置
var frame = CGRect(x: Z_SCREEN_WIDTH - 70,y: 42, width: 60,height: 30)
/// 背景颜色
var backgroundColor = UIColor.black.withAlphaComponent(0.4)
/// 文字
var text: NSString = "跳过"
/// 字体大小
var textFont = UIFont.systemFont(ofSize: 14)
/// 字体颜色
var textColor = UIColor.white
/// 数字大小
var timeFont = UIFont.systemFont(ofSize: 15)
/// 数字颜色
var timeColor = UIColor.red
/// 跳过按钮类型
var skipBtnType: ZLaunchSkipButtonType = .textLeftTimerRight
/// 圆形进度颜色
var strokeColor = UIColor.red
/// 圆形进度宽度
var lineWidth: CGFloat = 2
/// 圆角
var cornerRadius: CGFloat = 5
/// 边框颜色
var borderColor: UIColor = UIColor.clear
/// 边框宽度
var borderWidth: CGFloat = 1
  • ZLaunchAdImageResourceConfigure:配置广告图
/// image本地图片名(jpg/gif图片请带上扩展名)或网络图片URL
var imageNameOrImageURL: String?
/// 广告显示时间
var imageDuration: Int = 3
/// 图片缓存策略
var imageOptions: ZLaunchAdImageOptions = .readCache
/// 广告图大小
var imageFrame = CGRect(x: 0, y: 0, width: Z_SCREEN_WIDTH, height: Z_SCREEN_HEIGHT-100)
/// 过渡动画
var animationType: ZLaunchAnimationType = .crossDissolve

清除缓存

/// 清除全部缓存
ZLaunchAd.clearDiskCache()

/// 清除指定url的缓存
let array = ["http://..", "http://..", "http://..", "http://.."]
ZLaunchAd.clearDiskCacheWithImageUrlArray(array)

依赖

安装

  • 1.pod 'ZLaunchAd'

  • 2.pod install / pod update

联系

LICENSE

ZLaunchAd is released under the MIT license. See LICENSE for details.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK