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
})複製代碼