在执行异步 HTTP 请求时,我隐藏 iPhone 状态栏并在我自己的自定义 UIViewController 中设置动画以显示上传状态。因此,用户不会看到信号强度、运营商、时间和电池寿命,而是根据 HTTP 请求的进度获取消息。我的状态栏正好是 20px 高,非常适合以前的状态栏。当 HTTP 活动完成后,自定义视图动画出来,iPhone 状态栏动画化回来。
我想避免完全隐藏 iPhone 状态栏,而是将我的自定义视图放在状态栏的顶部。目前,如果我调用我的自定义视图动画并将 iPhone 状态栏设置为可见,我的自定义视图就在它后面。
这是我的代码:
-(void) animateStatusBarIn {
CGRect statusFrame = CGRectMake(0.0f, -20.0f, 320.0f, 20.0f);
UploadStatusBar *statusView = [[UploadStatusBar alloc] initWithNibName:@"UploadStatusBar" bundle:nil];
self.status = statusView;
[statusView release];
status.view.frame = statusFrame;
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
[window addSubview:status.view];
[UIView beginAnimations:@"slideDown" context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationFinished:)];
status.view.frame = CGRectMake(0.0f, 0.0f, 320.0f, 20.0f);
[UIView commitAnimations];
}
-(void) animateStatusBarOut {
[UIView beginAnimations:@"slideUp" context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationFinished:)];
status.view.frame = CGRectMake(0.0f, -20.0f, 320.0f, 20.0f);
[UIView commitAnimations];
}
-(void)animationFinished:(NSString *)name {
if ([name isEqualToString:@"slideDown"]) {
}
if ([name isEqualToString:@"slideUp"]) {
[[UIApplication sharedApplication]setStatusBarHidden:NO animated:YES];
[status.view removeFromSuperview];
}
}
没有 [[UIApplication sharedApplication]setStatusBarHidden:YES animated:YES] 你看不到我的自定义视图。我怎样才能让我的自定义视图只显示在状态栏的顶部,这样我就不必隐藏它了?
谢谢!