pod 'LBLaunchImageAd','~> 1.1.3'
如果发现pod search LBLaunchImageAd
搜索出来的不是最新版本,需要在终端执行cd转换文件路径命令退回到desktop,然后执行pod setup
命令更新本地spec缓存(可能需要几分钟),然后再搜索就可以了;也可以试下如下方法
rm ~/Library/Caches/CocoaPods/search_index.json
然后再pod search LBLaunchImageAd
本框架将用在涂嗨oh上线项目中,到时有兴趣的朋友可以下载看看效果
1.1.1 LaunchScreen.storyboard和LaunchImage无痕切换;如果需要把LaunchImage换成LaunchScreen.storyboard只需要删除LaunchImage然后创建LaunchScreen.storyboard然后到项目中的TARGETS --> APP Icons and Launch Images 修改LaunchScreen File 为LaunchScreen即可
效果图如下:
本框架依赖SDWebImage
导入#import "NSObject+LBLaunchImage.h"
在AppDelegate.m
的didFinishLaunchingWithOptions
方法中复制如下代码即可
//举个例子[LBNetWork PostAPI:url Dic:nil Suc:^(NSDictionary *Res)是自己封装的网络请求
[NSObject makeLBLaunchImageAdView:^(LBLaunchImageAdView *imgAdView) {
//设置广告的类型
imgAdView.getLBlaunchImageAdViewType(LogoAdType);
//自定义跳过按钮
imgAdView.skipBtn.backgroundColor = [UIColor lightGrayColor];
imgAdView.skipBtn.alpha = 0.5;
[imgAdView.skipBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
__block LBLaunchImageAdView *adView = imgAdView;
imgAdView.clickBlock = ^(const clickType type) {
switch (type) {
case clickAdType:{
NSLog(@"点击广告回调");
if (adView.advertUrl.length > 10 && adView.isClickAdView) {
LBAdVC *vc = [[LBAdVC alloc]init];
vc.url = adView.advertUrl;
vc.view.backgroundColor = [UIColor whiteColor];
if (self.tabBarController) {
[self.window setRootViewController:self.tabBarController];
}else{
[self setupViewControllers];
[self.window setRootViewController:self.tabBarController];
}
CYLTabBarController *tab = (CYLTabBarController *)_window.rootViewController;
UINavigationController *nav = (UINavigationController *)tab.viewControllers[0];
vc.hidesBottomBarWhenPushed = YES;
[nav pushViewController:vc animated:YES];
}
}
break;
case skipAdType:
NSLog(@"点击跳过回调");
if (self.tabBarController) {
[self.window setRootViewController:self.tabBarController];
}else{
[self setupViewControllers];
[self.window setRootViewController:self.tabBarController];
}
break;
case overtimeAdType:
NSLog(@"倒计时完成后的回调");
[self.window setRootViewController:self.tabBarController];
break;
default:
break;
}
};
///网络请求
[req startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
// NSLog(@"%@",request.responseJSONObject);
NSDictionary *dic = request.responseJSONObject;
if (dic) {
//设置网络启动图片URL
imgAdView.imgUrl = dic[@"imgURl"];
//点击响应的url
imgAdView.advertUrl = dic[@"clickURl"];
//是否能点击
imgAdView.isClickAdView = [dic[@"isClick"] boolValue];
}
} failure:^(__kindof YTKBaseRequest * _Nonnull request) {
}];
}];
__weak typeof(self) weakSelf = self;
[NSObject makeLBLaunchImageAdView:^(LBLaunchImageAdView *imgAdView) {
//设置广告的类型
imgAdView.getLBlaunchImageAdViewType(LogoAdType);
imgAdView.imgUrl = @"http://www.uisheji.com/wp-content/uploads/2013/04/19/app-design-uisheji-ui-icon20121_55.jpg";
//自定义跳过按钮
imgAdView.skipBtn.backgroundColor = [UIColor blackColor];
//各种点击事件的回调
imgAdView.clickBlock = ^(clickType type){
switch (type) {
case clickAdType:{
NSLog(@"点击广告回调");
TestViewController *vc = [[TestViewController alloc]init];
vc.view.backgroundColor = [UIColor whiteColor];
[weakSelf.window.rootViewController presentViewController:vc animated:YES completion:^{
}];
}
break;
case skipAdType:
NSLog(@"点击跳过回调");
break;
case overtimeAdType:
NSLog(@"倒计时完成后的回调");
break;
default:
break;
}
};
}];
__weak typeof(self) weakSelf = self;
[NSObject makeLBLaunchImageAdView:^(LBLaunchImageAdView *imgAdView) {
//设置广告的类型
imgAdView.getLBlaunchImageAdViewType(LogoAdType);
//设置本地启动图片
imgAdView.localAdImgName = @"qidong.gif";
//自定义跳过按钮
imgAdView.skipBtn.backgroundColor = [UIColor blackColor];
//各种点击事件的回调
imgAdView.clickBlock = ^(clickType type){
switch (type) {
case clickAdType:{
NSLog(@"点击广告回调");
TestViewController *vc = [[TestViewController alloc]init];
vc.view.backgroundColor = [UIColor whiteColor];
[weakSelf.window.rootViewController presentViewController:vc animated:YES completion:^{
}];
}
break;
case skipAdType:
NSLog(@"点击跳过回调");
break;
case overtimeAdType:
NSLog(@"倒计时完成后的回调");
break;
default:
break;
}
};
}];