美文网首页iOS 开发进阶
iOS 导航栏隐藏终极大法

iOS 导航栏隐藏终极大法

作者: 屈涯 | 来源:发表于2019-01-17 11:41 被阅读6次

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

#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

相关文章

网友评论

    本文标题:iOS 导航栏隐藏终极大法

    本文链接:https://www.haomeiwen.com/subject/luzbdqtx.html