JXPagerView+RQExtension.m 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // JXPagerView+RQExtension.m
  3. // JSJP
  4. //
  5. // Created by 张嵘 on 2021/10/26.
  6. //
  7. #import "JXPagerView+RQExtension.h"
  8. #import <objc/runtime.h>
  9. static NSString *isMirrorKey = @"isMirrorKey"; //isMirror的key
  10. @interface JXPagerView (RQExtension)
  11. @property (nonatomic, weak) id<JXPagerViewDelegate> delegate;
  12. @end
  13. @implementation JXPagerView (RQExtension)
  14. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  15. if (self.isMirror) {
  16. return 1;
  17. } else {
  18. return [self.delegate heightForPinSectionHeaderInPagerView:self];
  19. }
  20. }
  21. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  22. if (self.isMirror) {
  23. UIView *header = [[UIView alloc] initWithFrame:CGRectZero];
  24. header.backgroundColor = [UIColor clearColor];
  25. return header;
  26. } else {
  27. return [self.delegate viewForPinSectionHeaderInPagerView:self];
  28. }
  29. }
  30. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  31. if (self.isMirror) {
  32. return [self.delegate heightForPinSectionHeaderInPagerView:self];
  33. } else {
  34. return 1;
  35. }
  36. }
  37. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  38. if (self.isMirror) {
  39. return [self.delegate viewForPinSectionHeaderInPagerView:self];
  40. } else {
  41. UIView *footer = [[UIView alloc] initWithFrame:CGRectZero];
  42. footer.backgroundColor = [UIColor clearColor];
  43. return footer;
  44. }
  45. }
  46. - (void)setIsMirror:(BOOL)isMirror {
  47. objc_setAssociatedObject(self, &isMirrorKey, @(isMirror), OBJC_ASSOCIATION_ASSIGN);
  48. }
  49. - (BOOL)isMirror {
  50. return [objc_getAssociatedObject(self, &isMirrorKey) boolValue];
  51. }
  52. @end