一、定義全局成員變量app
@interface AppDelegate ()atom
@property (strong, nonatomic) UIImageView *adImageView;spa
@property (strong, nonatomic) UINavigationController *rootNavi;rest
@endorm
二、實現簡單廣告界面rem
@implementation AppDelegateanimation
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {it
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];io
TextViewController* mainVC = [[TextViewController alloc] init];form
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:mainVC];
self.rootNavi = nav;
if ([[UIDevice currentDevice].systemVersion doubleValue] < 7.0) {
[nav.navigationBar setBarTintColor:[UIColor clearColor]];
} else {
[nav.navigationBar setTintColor:[UIColor clearColor]];
}
注意:必定要設置空的rootViewController
UIViewController *emptyView = [[ UIViewController alloc ] initWithNibName:nil bundle:nil];
self. window .rootViewController = emptyView;
self.adImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
[self.adImageView setImage:[UIImage imageNamed:@"bg_welcome"]];
[self.window addSubview:self.adImageView];
[self performSelector:@selector(removeAdImageView) withObject:nil afterDelay: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;
[self restoreRootViewController:self.rootNavi];
}];
}
- (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];
}
@end
四、如需實現倒計時、跳過只須要自定義View去操做就ok
............