FLEXTableColumnHeader.m 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // FLEXTableContentHeaderCell.m
  3. // FLEX
  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. UILabel *_arrowLabel;
  11. }
  12. - (instancetype)initWithFrame:(CGRect)frame {
  13. self = [super initWithFrame:frame];
  14. if (self) {
  15. self.backgroundColor = UIColor.whiteColor;
  16. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, frame.size.width - 25, frame.size.height)];
  17. label.font = [UIFont systemFontOfSize:13.0];
  18. [self addSubview:label];
  19. self.label = label;
  20. _arrowLabel = [[UILabel alloc] initWithFrame:CGRectMake(frame.size.width - 20, 0, 20, frame.size.height)];
  21. _arrowLabel.font = [UIFont systemFontOfSize:13.0];
  22. [self addSubview:_arrowLabel];
  23. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(frame.size.width - 1, 2, 1, frame.size.height - 4)];
  24. line.backgroundColor = [UIColor colorWithWhite:0.803 alpha:0.850];
  25. [self addSubview:line];
  26. }
  27. return self;
  28. }
  29. - (void)changeSortStatusWithType:(FLEXTableColumnHeaderSortType)type {
  30. switch (type) {
  31. case FLEXTableColumnHeaderSortTypeNone:
  32. _arrowLabel.text = @"";
  33. break;
  34. case FLEXTableColumnHeaderSortTypeAsc:
  35. _arrowLabel.text = @"⬆️";
  36. break;
  37. case FLEXTableColumnHeaderSortTypeDesc:
  38. _arrowLabel.text = @"⬇️";
  39. break;
  40. }
  41. }
  42. @end