-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
你好,弹出的时候怎么改变状态栏的颜色? #5
Comments
__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
|
多谢大神 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
你好,弹出的时候怎么改变状态栏的颜色?
我设置了
-(UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleDefault;
}
没有效果,求解
The text was updated successfully, but these errors were encountered: