APP启动图之后,淡入淡出广告页,用户可以选择跳过广告。很多APP都有类似的功能。如下图:
APP广告页.gifOC实现方法:(LBLaunchImage文件需要结合SDWebImage一起使用)
在AppDeleagte.h文件中,引入LBLaunchImage
#import "AppDelegate.h"
#import "LBLaunchImageAdView.h"
#import "TestViewController.h"
在下边方法内实现如下代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
/* FullScreenAdType 全屏广告
* LogoAdType 带logo的广告类似网易广告,值得注意的是启动图片必须带logo图
* ImgUrl 图片url
*/
LBLaunchImageAdView * adView = [[LBLaunchImageAdView alloc]initWithWindow:self.window andType:FullScreenAdType andImgUrl:@"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:{
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;
}
};
return YES;
}
Swift实现:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let adView = LBLaunchImageAdView(window: window, andType: 1, andImgUrl: "http://www.uisheji.com/wp-content/uploads/2013/04/19/app-design-uisheji-ui-icon20121_55.jpg")
adView.clickBlock = { tag in
switch tag {
case 1100:
print("点击广告回调")
case 1101:
print("点击跳过回调")
break;
case 1102:
print("倒计时完成后的回调")
default: break
}
}
// Override point for customization after application launch.
return true
}
网友评论