自iOS 7推出以来,我无法像iOS 6那样显示或隐藏动画状态栏 . 现在我使用NSTimer控制它何时隐藏 .
这是我的代码:
- (void)hideStatusBar{
_isStatusBarHidden=YES;
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
}
- (void)showStatusBar{
_isStatusBarHidden=NO;
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
}
//===================
_controlVisibilityTimer = [[NSTimer scheduledTimerWithTimeInterval:4 target:self selector:@selector(hideStatusBar:) userInfo:nil repeats:NO] retain];
但不幸的是,状态栏隐藏的方式似乎有点粗糙,没有消失 . 有人在那里有解决方案吗?
更新
我使用@hahaha解决方案解决了隐藏问题 . 我只需要一个视图作为状态栏的背景,这是我的代码 .
AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication]delegate];
self.StatusBarOrange = [[UIView alloc] initWithFrame:CGRectMake(0, 0, appDelegate.window.frame.size.width, 20)];
[self.StatusBarOrange setBackgroundColor:[UIColor orangeColor]];
[appDelegate.window.rootViewController.view addSubview:self.StatusBarOrange];
现在一切都很完美!
1 回答
你需要打电话
从动画块中,如下例所示: