FLEXTableViewCell.m 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // FLEXTableViewCell.m
  3. // FLEX
  4. //
  5. // Created by Tanner on 4/17/19.
  6. // Copyright © 2019 Flipboard. 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. self.subtitleLabel.textColor = FLEXColor.deemphasizedTextColor;
  34. self.titleLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
  35. self.subtitleLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
  36. self.titleLabel.numberOfLines = 1;
  37. self.subtitleLabel.numberOfLines = 1;
  38. }
  39. - (UILabel *)titleLabel {
  40. return self.textLabel;
  41. }
  42. - (UILabel *)subtitleLabel {
  43. return self.detailTextLabel;
  44. }
  45. @end