美文网首页
iOS UIWiondow 隐藏, 显示 ,设置颜色方法

iOS UIWiondow 隐藏, 显示 ,设置颜色方法

作者: 追赶时间 | 来源:发表于2016-12-08 22:45 被阅读11次

    @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

    相关文章

      网友评论

          本文标题:iOS UIWiondow 隐藏, 显示 ,设置颜色方法

          本文链接:https://www.haomeiwen.com/subject/xytemttx.html