项目介绍:
LBLaunchImageAd
效果图如下:
本框架依赖SDWebImage
导入LBLaunchImageAd
在AppDelegate.m
的didFinishLaunchingWithOptions
方法中复制如下代码即可
如果需要网络请求得到URL的例子如下
//初始化一个adView
LBLaunchImageAdView * adView = [[LBLaunchImageAdView alloc]init];
//举个例子[LBNetWork PostAPI:url Dic:nil Suc:^(NSDictionary *Res)是自己封装的网络请求
[LBNetWork PostAPI:url Dic:nil Suc:^(NSDictionary *Res) {
NSArray *arr = Res[@"resultContent"];
NSString *imgURL = nil;
for (NSDictionary *dic in arr) {
imgURL = [NSString stringWithFormat:@"xxxxx%@",dic[@"imgpath"]] ;
}
//关键地方
if (imgURL) {
adView.getLBlaunchImageAdViewType(LogoAdType);
adView.imgUrl = imgURL;
//各种回调
adView.clickBlock = ^(NSInteger tag){
switch (tag) {
case 1100:{
}
break;
case 1101:
NSLog(@"点击跳过回调");
self.window.rootViewController = _tabBarController;
break;
case 1102:
NSLog(@"倒计时完成后的回调");
self.window.rootViewController = _tabBarController;
break;
default:
break;
}
};
}
} Fai:^(NSURLSessionDataTask *operation) {
}];
如果直接是固定的图片Url
LBLaunchImageAdView * adView = [[LBLaunchImageAdView alloc]init];
adView.getLBlaunchImageAdViewType(LogoAdType);
adView.imgUrl = @"http://www.uisheji.com/wp-content/uploads/2013/04/19/app-design-uisheji-ui-icon20121_55.jpg";
adView.clickBlock = ^(NSInteger tag){
switch (tag) {
case 1100:{
}
break;
case 1101:
NSLog(@"点击跳过回调");
self.window.rootViewController = _tabBarController;
break;
case 1102:
NSLog(@"倒计时完成后的回调");
self.window.rootViewController = _tabBarController;
break;
default:
break;
}
};
如果是本地图片
LBLaunchImageAdView * adView = [[LBLaunchImageAdView alloc]init];
adView.getLBlaunchImageAdViewType(LogoAdType);
adView.localAdImgName = @"qidong.png";
//各种回调
adView.clickBlock = ^(NSInteger tag){
switch (tag) {
case 1100:{
NSLog(@"点击广告回调");
TestViewController *vc = [[TestViewController alloc]init];
vc.view.backgroundColor = [UIColor whiteColor];
[self.window.rootViewController presentViewController:vc animated:YES completion:^{
}];
}
break;
case 1101:
NSLog(@"点击跳过回调");
break;
case 1102:
NSLog(@"倒计时完成后的回调");
break;
default:
break;
}
};
github地址:
https://github.com/AllLuckly/LBLaunchImageAd