1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- //
- // UIViewController+TD.m
- // smartRhino
- //
- // Created by tederen on 2019/10/22.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "UIViewController+TD.h"
- #import <objc/runtime.h>
- static NSString *statusBar = @"statusBar";
- @interface NSObject ()
- @end
- @implementation UIViewController (TD)
- /**
- setter方法
- */
- - (void)setStatusBar:(UIView *)barView {
- objc_setAssociatedObject(self, &statusBar, barView, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
- }
- /**
- getter方法
- */
- - (UIView *)statusBar {
- return objc_getAssociatedObject(self, &statusBar);
- }
- - (void)loadStatusBarColor:(UIColor *)color {
- if (!self.statusBar) {
- UIView *barView = [UIView new];
- barView.frame = CGRectMake(0, 0, kGXScreenWidth, IS_IPHONEX ? 44 : 20);
- [self setStatusBar:barView];
- [self.view addSubview:self.statusBar];
- }
- self.statusBar.backgroundColor = color;
- }
- @end
|