FLEXTableColumnHeader.m 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // FLEXTableContentHeaderCell.m
  3. // UICatalog
  4. //
  5. // Created by Peng Tao on 15/11/26.
  6. // Copyright © 2015年 f. All rights reserved.
  7. //
  8. #import "FLEXTableColumnHeader.h"
  9. @implementation FLEXTableColumnHeader
  10. {
  11. UILabel *_arrowLabel;
  12. }
  13. - (instancetype)initWithFrame:(CGRect)frame
  14. {
  15. self = [super initWithFrame:frame];
  16. if (self) {
  17. self.backgroundColor = [UIColor whiteColor];
  18. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, frame.size.width - 25, frame.size.height)];
  19. label.font = [UIFont systemFontOfSize:13.0];
  20. [self addSubview:label];
  21. self.label = label;
  22. _arrowLabel = [[UILabel alloc] initWithFrame:CGRectMake(frame.size.width - 20, 0, 20, frame.size.height)];
  23. _arrowLabel.font = [UIFont systemFontOfSize:13.0];
  24. [self addSubview:_arrowLabel];
  25. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(frame.size.width - 1, 2, 1, frame.size.height - 4)];
  26. line.backgroundColor = [UIColor colorWithWhite:0.803 alpha:0.850];
  27. [self addSubview:line];
  28. }
  29. return self;
  30. }
  31. - (void)changeSortStatusWithType:(FLEXTableColumnHeaderSortType)type
  32. {
  33. switch (type) {
  34. case FLEXTableColumnHeaderSortTypeNone:
  35. _arrowLabel.text = @"";
  36. break;
  37. case FLEXTableColumnHeaderSortTypeAsc:
  38. _arrowLabel.text = @"⬆️";
  39. break;
  40. case FLEXTableColumnHeaderSortTypeDesc:
  41. _arrowLabel.text = @"⬇️";
  42. break;
  43. default:
  44. break;
  45. }
  46. }
  47. @end