FLEXTableViewCell.m 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // FLEXTableViewCell.m
  3. // FLEX
  4. //
  5. // Created by Tanner on 4/17/19.
  6. // Copyright © 2020 FLEX Team. All rights reserved.
  7. //
  8. #import "FLEXTableViewCell.h"
  9. #import "FLEXUtility.h"
  10. #import "FLEXColor.h"
  11. #import "FLEXTableView.h"
  12. @interface UITableView (Internal)
  13. // Exists at least since iOS 5
  14. - (BOOL)_canPerformAction:(SEL)action forCell:(UITableViewCell *)cell sender:(id)sender;
  15. - (void)_performAction:(SEL)action forCell:(UITableViewCell *)cell sender:(id)sender;
  16. @end
  17. @interface UITableViewCell (Internal)
  18. // Exists at least since iOS 5
  19. @property (nonatomic, readonly) FLEXTableView *_tableView;
  20. @end
  21. @implementation FLEXTableViewCell
  22. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  23. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  24. if (self) {
  25. [self postInit];
  26. }
  27. return self;
  28. }
  29. - (void)postInit {
  30. UIFont *cellFont = UIFont.flex_defaultTableCellFont;
  31. self.titleLabel.font = cellFont;
  32. self.subtitleLabel.font = cellFont;
  33. #if !TARGET_OS_TV
  34. self.subtitleLabel.textColor = FLEXColor.deemphasizedTextColor;
  35. #endif
  36. self.titleLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
  37. self.subtitleLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
  38. self.titleLabel.numberOfLines = 1;
  39. self.subtitleLabel.numberOfLines = 1;
  40. }
  41. - (UILabel *)titleLabel {
  42. return self.textLabel;
  43. }
  44. - (UILabel *)subtitleLabel {
  45. return self.detailTextLabel;
  46. }
  47. @end