iOS 导航栏隐藏终极大法

写一个分类,需要用到的控制器

#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

猜你喜欢

转载自blog.csdn.net/weixin_34277853/article/details/87271969