1.设置方法:在Assets.xcassets中新建LaunchImage
2.在项目 TARGETS->General->App Icons and Launch Images
中设置 Launch Images Source
为LaunchImage,并将 Launch Screen File
设为空(如图)
1.如图
3.在AppDelegate中导入XHLaunchAd.h 头文件,在didFinishLaunchingWithOptions:方法中调用下面代码
//1.初始化启动页广告(初始化后,自动添加至视图,不用手动添加) XHLaunchAd *launchAd = [[XHLaunchAd alloc] initWithFrame:CGRectMake(0, 0,self.window.bounds.size.width, self.window.bounds.size.height-150) andDuration:5]; //2.设置启动页广告图片的url(必须)-(支持jpg/png静态图,及gif动态图) NSString *imgUrlString =@"http://img.taopic.com/uploads/allimg/120906/219077-120Z616330677.jpg"; [launchAd imgUrlString:imgUrlString options:XHWebImageRefreshCached completed:^(UIImage *image, NSURL *url) { //异步加载图片完成回调(若需根据图片实际尺寸,刷新广告frame,可在这里操作) //launchAd.adFrame = ...; }]; //是否影藏'倒计时/跳过'按钮[默认显示](可选) launchAd.hideSkip = NO; //广告点击事件(可选) launchAd.clickBlock = ^() { NSString *url = @"https://www.baidu.com"; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; };
/** * 清除图片本地缓存 */ +(void)clearDiskCache; /** * 获取缓存图片占用总大小(M) */ + (float)imagesCacheSize;
XHLaunchAd 使用 MIT 许可证,详情见 LICENSE 文件