ZLaunchAdVC
集成启动广告,支持LaunchImage
和LaunchScreen
,支持GIF,支持本地图片,支持视图过渡动画- 使用
viewController
作启动页广告,经过切换rootViewController
,避免闪出首页控制器,避免处理复杂的层级关系- GitHub: https://github.com/MQZHot/ZLaunchAdVC 不足之处,欢迎交流,欢迎star✨✨✨✨✨✨✨✨✨✨
- 更新: 2017-11-10
didFinishLaunchingWithOptions
中设置ZLaunchAdVC
为rootViewController
,指定广告完成后展现的控制器,并配置广告的参数使用经过推送、DeepLink等启动时,是否须要展现广告也能够灵活配置git
/// 加载广告
let adVC = ZLaunchAdVC(waitTime: 4,rootVC: nav)
request { model in
adVC.configure { button, adView in
button.skipBtnType = model.skipBtnType
adView.animationType = model.animationType
adView.adFrame = CGRect(x: 0, y: 0, width: Z_SCREEN_WIDTH, height: Z_SCREEN_WIDTH*model.height/model.width)
}.setImage(model.imgUrl, duration: model.duration, options: .readCache, action: {
let vc = UIViewController()
vc.view.backgroundColor = UIColor.yellow
homeVC.navigationController?.pushViewController(vc, animated: true)
})
}
window?.rootViewController = adVC复制代码
configure
方法配置广告参数,configure
为闭包/// 按钮位置
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复制代码
/// 广告图大小
var adFrame = CGRect(x: 0, y: 0, width: Z_SCREEN_WIDTH, height: Z_SCREEN_HEIGHT-100)
/// 过渡动画
var animationType: ZLaunchAnimationType = .crossDissolve复制代码
加载网络图片github
let url = "http://chatm-icon.oss-cn-beijing.aliyuncs.com/pic/pic_20170724152928869.gif"
adVC.setImage(url, duration: 5, options: .readCache, action: {
/// do something
})复制代码
设置本地图片swift
adVC.setImage(UIImage(named: "222"), duration: 7, action: {
/// do something
})复制代码
adVC.setGif("111", duration: 7, action: {
/// do something
})复制代码