IOS使用Category时候动态为类添加属性:
#import <UIKit/UIKit.h>
#import "JTNavigationController.h"
@interface UIViewController (JTNavigationExtension)
//是否允许滑动
@property (nonatomic, assign) BOOL jt_screenPopGestureEnabled;
@end
#import "UIViewController+JTNavigationExtension.h"
#import <objc/runtime.h>
@implementation UIViewController (JTNavigationExtension)
/************jt_screenPopGestureEnabled************/
-(void)setJt_screenPopGestureEnabled:(BOOL)jt_screenPopGestureEnabled{
objc_setAssociatedObject(self, @selector(jt_screenPopGestureEnabled), @(jt_screenPopGestureEnabled), OBJC_ASSOCIATION_RETAIN);
}
-(BOOL)jt_screenPopGestureEnabled{
return [objc_getAssociatedObject(self, _cmd) boolValue];
}
@end