----|------|-------|
演示項目
|
|
|
|---|
API
/**
* 初始化啟動頁
*
* @param adDuration 停留時間
* @param hideSkip 是否隱藏跳過
* @param setLaunchAd launchAdView
*
* @return self
*/
+ (instancetype)initImageWithAttribute:(NSInteger)adDuration showSkipType:(SkipShowType)showSkipType setLaunchAd:(JWSetLaunchAdBlock)setLaunchAd;
/**
* 設置圖片
*
* @param strURL URL
* @param options 圖片緩沖模式
* @param result UIImage *image, NSURL *url
* @param adClickBlock 點擊圖片回調(diào)
*/
- (void)setWebImageWithURL:(NSString *)strURL options:(JWWebImageOptions)options result:(JWWebImageCompletionBlock)result adClickBlock:(JWLaunchAdClickBlock)adClickBlock;
/**
* 設置動畫跳過屬性
*
* @param strokeColor 轉動顏色
* @param lineWidth 寬度
* @param backgroundColor 背景色
* @param textColor 字體顏色
*/
- (void)setAnimationSkipWithAttribute:(UIColor *)strokeColor lineWidth:(NSInteger)lineWidth backgroundColor:(UIColor *)backgroundColor textColor:(UIColor *)textColor;
/**
* 廣告圖Frame
*/
@property (assign, nonatomic) CGRect launchAdViewFrame;
使用
在AppDelegate中設置Window.rootViewController之后調(diào)用下面方法:
// 1.設置啟動頁廣告圖片的URL
NSString *imgUrlString =@"http://imgstore.cdn.sogou.com/app/a/100540002/714860.jpg";
// 2.初始化啟動頁
[JWLaunchAd initImageWithAttribute:6.0 showSkipType:SkipShowTypeAnimation setLaunchAd:^(JWLaunchAd *launchAd) {
__block JWLaunchAd *weakSelf = launchAd;
//如果選擇 SkipShowTypeAnimation 需要設置動畫跳過按鈕的屬性
[weakSelf setAnimationSkipWithAttribute:[UIColor redColor] lineWidth:3.0 backgroundColor:nil textColor:nil];
[launchAd setWebImageWithURL:imgUrlString options:JWWebImageDefault result:^(UIImage *image, NSURL *url) {
// 異步緩沖圖片完成后調(diào)整圖片F(xiàn)rame
weakSelf.launchAdViewFrame = CGRectMake(0, 0, kScreen_Width, kScreen_Height-100);
}adClickBlock:^{
// 3.廣告回調(diào)
NSString *url = @"https://www.baidu.com";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}];
}];
安裝
//CocoaPods
1. 在Podfile添加 pod 'JWLaunchAd'.
2. 運行 pod install 或 pod update.
3. import "JWLaunchAd.h".
//手動安裝
1. 將JWLaunchAd導入你的Xcode項目.
2. import "JWLaunchAd.h".