写一个分类,需要用到的控制器
#import <UIKit/UIKit.h>
@interface UIViewController (NavigationBar)
@property (nonatomic, assign) BOOL fy_barHidden;
@end
#import "UIViewController+NavigationBar.h"
#import <objc/runtime.h>
@implementation UIViewController (NavigationBar)
- (void)setFy_barHidden:(BOOL)fy_barHidden
{
objc_setAssociatedObject(self, @selector(fy_barHidden), @(fy_barHidden), OBJC_ASSOCIATION_RETAIN);
}
- (BOOL)fy_barHidden
{
return [objc_getAssociatedObject(self, @selector(fy_barHidden)) boolValue];
}
@end
网友评论