我在“didFinishLaunchingWithOptions”方法中创建了动画启动画面。动画启动画面持续时间为2秒。两秒钟后,我隐藏了动画启动画面。当出现动画屏幕时,我想隐藏状态栏,当动画屏幕消失时,我想显示状态栏。
怎么做?
//我在这里创建动画启动画面
** * ** 这里我要隐藏状态栏* * ** * **
splashView =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 580)];
splashView.backgroundColor =[UIColor whiteColor];
[self.window addSubview:splashView];
logoView = [[UIImageView alloc] initWithFrame:CGRectMake(logoX,0, 225, 25)];
logoView.image = [UIImage imageNamed:@"logoImage"];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
splashView.alpha = 1.0;
logoView.frame = CGRectMake(logoX, logoY, 225, 25);
[window addSubview:logoView];
[window bringSubviewToFront:logoView];
[UIView commitAnimations];
//隐藏动画启动画面2秒钟后
- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
************* Here i want to show Status bar Again ***************
[splashView removeFromSuperview];
[logoView removeFromSuperview];
}
答案 0 :(得分:2)
你进入ProjectSettings - >一般。有一个选项Status Bar Style
。
修改强> 使用块。它们为动画提供了非常简单的语法。
[UIView animateWithDuration:2.0 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
//your animation code here
//all changes made here to frame, bounds, alpha etc. are animated
} completion:^(BOOL finished) {
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
//this is called after animation finishes
}];
答案 1 :(得分:1)
在plist文件中添加以下条目:
答案 2 :(得分:0)
您可以为UIViewController创建一个类别
@implementation UIViewController (HideStatusBar)
-(BOOL)prefersStatusBarHidden
{
return YES;
}