iOS 启动图片,之后的广告图片效果
2016-05-17 12:07
477 查看
iOS 应用添加开屏广告
在AppDelegate.h中的代码
在AppDelegate.m中的代码
文/Lonely__(简书作者)
原文链接:http://www.jianshu.com/p/6dc2713bf8d1
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
在AppDelegate.h中的代码
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) UIImageView *adImageView; @property (strong, nonatomic) UINavigationController *rootNavi; @end
在AppDelegate.m中的代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds]]; // Override point for customization after application launch. AlertDemoViewController *vc = [[AlertDemoViewController alloc]init]; UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:vc]; if (isIOS7) { [navi.navigationBar setBarTintColor:[UIColor clearColor]]; }else{ [navi.navigationBar setTintColor:[UIColor clearColor]]; } self.rootNavi = navi; //self.window.rootViewController = navi; self.adImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen]bounds].size.height)]; [self.adImageView setImage:[UIImage imageNamed:@"tmplecture"]]; [self.window addSubview:self.adImageView]; [self performSelector:@selector(removeAdImageView) withObject:nilafterDelay:3]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; } - (void)removeAdImageView { [UIView animateWithDuration:0.3f animations:^{ self.adImageView.transform = CGAffineTransformMakeScale(0.5f,0.5f); self.adImageView.alpha = 0.f; } completion:^(BOOL finished) { [self.adImageView removeFromSuperview]; self.window.rootViewController = self.rootNavi; }]; }
淡入淡出更换 rootViewController
- (void)restoreRootViewController:(UIViewController *)rootViewController { typedef void (^Animation)(void); UIWindow* window = self.window; rootViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; Animation animation = ^{ BOOL oldState = [UIView areAnimationsEnabled]; [UIView setAnimationsEnabled:NO]; window.rootViewController = rootViewController; [UIView setAnimationsEnabled:oldState]; }; [UIView transitionWithView:window duration:0.5f options:UIViewAnimationOptionTransitionCrossDissolve animations:animation completion:nil]; }
文/Lonely__(简书作者)
原文链接:http://www.jianshu.com/p/6dc2713bf8d1
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
相关文章推荐
- IOS之分析网易新闻存储数据(CoreData的使用,增删改查)
- iOS开发之多语言
- iOS设计模式(二) 简单工厂,工厂,抽象工厂
- js 通过userAgent判断是安卓还是ios
- iOS自带MD5加密
- iOS开发 ☞ IPv6
- ios kvo 监听值遇到的问题
- iOS开发之诱导用户为自己的App评论功能
- iOS 下拉菜单
- IOS 多线程编程指南之NSThread
- ios彩票端 摇一摇的实现
- 将cordova嵌入iOS应用
- nagios无法载入静态资源
- iOS开发之沙盒机制
- ios 音频
- iOS 点击图片放大效果
- 欢迎使用CSDN-markdown编辑器
- 整理iOS工作学习过程中遇到的各种问题
- AVSpeechSynthesizer详解
- iOS横竖屏转换问题