UIView+XIB.m 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // UIView+XIB.m
  3. // HCQuanfangtong
  4. //
  5. // Created by qft_Ios_03 on 2018/5/18.
  6. // Copyright © 2018年 qft_Ios_03. All rights reserved.
  7. //
  8. #import "UIView+XIB.h"
  9. #import <objc/runtime.h>
  10. @implementation UIView (XIB)
  11. + (instancetype )replyViewFirst{
  12. [[self class] fixTextViewCrash];
  13. NSArray *array = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil];
  14. UIView *v = [array firstObject];
  15. return v;
  16. }
  17. +(void)fixTextViewCrash {
  18. if (@available(iOS 13.2,*)) {
  19. }else{
  20. const char *className = "_UITextLayoutView";
  21. Class clas = objc_getClass(className);
  22. if (clas == nil) {
  23. clas = objc_allocateClassPair([UIView class], className, 0);
  24. objc_registerClassPair(clas);
  25. }
  26. }
  27. }
  28. - (void)setIsFold:(int)isFold{
  29. objc_setAssociatedObject(self, @"isFold", [NSNumber numberWithBool:isFold], OBJC_ASSOCIATION_ASSIGN);
  30. }
  31. - (int)isFold{
  32. return [objc_getAssociatedObject(self, @"isFold") boolValue];
  33. }
  34. - (void)setUpdateAudit:(void (^)(NSString *remark,UIView *sender))updateAudit{
  35. objc_setAssociatedObject(self, @"updateAudit", updateAudit, OBJC_ASSOCIATION_COPY);
  36. }
  37. - (void (^)(NSString *remark,UIView *sender))updateAudit{
  38. return objc_getAssociatedObject(self, @"updateAudit");
  39. }
  40. - (void)setChangeClick:(void (^)(NSInteger))ChangeClick{
  41. objc_setAssociatedObject(self, @"ChangeClick", ChangeClick, OBJC_ASSOCIATION_COPY);
  42. }
  43. - (void (^)(NSInteger))ChangeClick{
  44. return objc_getAssociatedObject(self, @"ChangeClick");
  45. }
  46. - (void)setUpdateObj:(id)updateObj{
  47. objc_setAssociatedObject(self, @"updateObj", updateObj, OBJC_ASSOCIATION_COPY);
  48. }
  49. - (void)setSaleType:(NSString *)saleType {
  50. objc_setAssociatedObject(self, @"saleType", saleType, OBJC_ASSOCIATION_COPY);
  51. }
  52. - (id)updateObj{
  53. return objc_getAssociatedObject(self, @"updateObj");
  54. }
  55. @end