添加自定义方法 hideStatusbar 到我们的类
它隐藏了状态栏动画并调整我们的视图大小以占据状态栏空间。
-(void)hideStatusbar {
[[UIApplication sharedApplication] setStatusBarHidden:YES
withAnimation:UIStatusBarAnimationFade];
[UIView beginAnimations:@"Statusbar hide" context:nil];
[UIView setAnimationDuration:0.5];
[self.view setFrame:CGRectMake(0, 0, 320, 480)];
[UIView commitAnimations];
}
更新 ViewController.m 中的 viewDidLoad 如下 -
- (void)viewDidLoad {
[super viewDidLoad];
// The method hideStatusbar called after 2 seconds
[self performSelector:@selector(hideStatusbar)
withObject:nil afterDelay:2.0];
// Do any additional setup after loading the view, typically from a nib.
}
初始输出和 2 秒后输出 -