@interface ViewController ()
@property (nonatomic, assign) UIStatusBarStyle statusBarStyle;
@property (nonatomic, assign) BOOL statusBarHidden;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = [UIColor grayColor];
}
- (IBAction)change1:(UISegmentedControl *)sender {
if (sender.selectedSegmentIndex == 0) { // 隐藏
[XMGTopWindowViewController sharedInstance].statusBarHidden = YES;
XMGSetStatusBarHidden(YES)
XMGHideStatusBar
} else { // 显示
XMGSetStatusBarHidden(NO)
XMGShowStatusBar
[XMGTopWindowViewController sharedInstance].statusBarHidden = NO;
}
}
- (IBAction)change2:(UISegmentedControl *)sender {
if (sender.selectedSegmentIndex == 0) { // 黑色
XMGBlackStatusBar
[XMGTopWindowViewController sharedInstance].statusBarStyle = UIStatusBarStyleDefault;
} else { // 白色
XMGWhiteStatusBar
[XMGTopWindowViewController sharedInstance].statusBarStyle = UIStatusBarStyleLightContent;
}
}
- (UIStatusBarStyle)preferredStatusBarStyle
{
return self.statusBarStyle;
}
- (BOOL)prefersStatusBarHidden
{
return self.statusBarHidden;
}
- (IBAction)change1:(UISegmentedControl *)sender {
if (sender.selectedSegmentIndex == 0) { // 隐藏
self.statusBarHidden = YES;
} else { // 显示
self.statusBarHidden = NO;
}
// 更新状态栏
[self setNeedsStatusBarAppearanceUpdate];
}
- (IBAction)change2:(UISegmentedControl *)sender {
if (sender.selectedSegmentIndex == 0) { // 黑色
self.statusBarStyle = UIStatusBarStyleDefault;
} else { // 白色
self.statusBarStyle = UIStatusBarStyleLightContent;
}
// 更新状态栏
[self setNeedsStatusBarAppearanceUpdate];
}
@end