GithubHelp home page GithubHelp logo

Comments (2)

snail-z avatar snail-z commented on May 20, 2024
    __weak typeof(self) w_self = self;
    self.sl_popupController.willPresent = ^(SnailPopupController * _Nonnull popupController) {
        [w_self sl_setStatusBarStyle:UIStatusBarStyleLightContent];
    };
    
    self.sl_popupController.didDismiss = ^(SnailPopupController * _Nonnull popupController) {
        [w_self sl_setStatusBarStyle:UIStatusBarStyleDefault];
    };
#import "UIViewController+StatusBar.h"
#import <objc/runtime.h>

@implementation UINavigationController (StatusBarStyle)

- (UIViewController *)childViewControllerForStatusBarStyle {
    return self.topViewController;
}

- (UIViewController *)childViewControllerForStatusBarHidden {
    return self.topViewController;
}

@end

static void *sl_UIViewControllerStatusBarStyleKey = &sl_UIViewControllerStatusBarStyleKey;
static void *sl_UIViewControllerStatusBarHiddenKey = &sl_UIViewControllerStatusBarHiddenKey;

@implementation UIViewController (StatusBar)

- (void)setIsLightContent:(BOOL)isLightContent {
    objc_setAssociatedObject(self, sl_UIViewControllerStatusBarStyleKey, @(isLightContent), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (BOOL)isLightContent {
    id value = objc_getAssociatedObject(self, sl_UIViewControllerStatusBarStyleKey);
    return [(NSNumber *)value boolValue];
}

- (void)setIsHidden:(BOOL)isHidden {
    objc_setAssociatedObject(self, sl_UIViewControllerStatusBarHiddenKey, @(isHidden), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (BOOL)isHidden {
    id value = objc_getAssociatedObject(self, sl_UIViewControllerStatusBarHiddenKey);
    return [(NSNumber *)value boolValue];
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    if (self.isLightContent) {
        return UIStatusBarStyleLightContent;
    }
    return UIStatusBarStyleDefault;
}

- (BOOL)prefersStatusBarHidden {
    return self.isHidden;
}

- (void)sl_setStatusBarStyle:(UIStatusBarStyle)statusBarStyle {
    self.isLightContent = statusBarStyle == UIStatusBarStyleLightContent;
    [self setNeedsStatusBarAppearanceUpdate];
}

- (void)sl_setStatusBarHidden:(BOOL)statusBarHidden {
    self.isHidden = statusBarHidden;
    [self setNeedsStatusBarAppearanceUpdate];
}

- (void)sl_resetStatusBarStyle {
    self.isLightContent = NO;
    self.isHidden = NO;
    [self setNeedsStatusBarAppearanceUpdate];
}

@end
#import <UIKit/UIKit.h>

@interface UIViewController (StatusBar)

- (void)sl_setStatusBarHidden:(BOOL)statusBarHidden;
- (void)sl_setStatusBarStyle:(UIStatusBarStyle)statusBarStyle;
- (void)sl_resetStatusBarStyle;

@end

from zhpopupcontroller.

ganjmeng avatar ganjmeng commented on May 20, 2024

多谢大神

from zhpopupcontroller.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.