LinesSelectCell.m 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // LinesSelectCell.m
  3. // LRSChartView
  4. //
  5. // Created by lihaiyang on 2018/10/23.
  6. // Copyright © 2018 lihaiyang. All rights reserved.
  7. //
  8. #import "LinesSelectCell.h"
  9. @interface LinesSelectCell ()
  10. //←lab
  11. @property (nonatomic ,strong) UILabel * titlesLab;
  12. //→lab
  13. @property (nonatomic ,strong) UILabel * descsLab;
  14. @end
  15. @implementation LinesSelectCell
  16. - (void)awakeFromNib {
  17. [super awakeFromNib];
  18. // Initialization code
  19. }
  20. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  21. [super setSelected:selected animated:animated];
  22. // Configure the view for the selected state
  23. }
  24. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  25. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  26. self.backgroundColor = [UIColor clearColor];
  27. _titlesLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 0, 17)];
  28. [self addSubview:_titlesLab];
  29. _descsLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 0, 17)];
  30. [self addSubview:_descsLab];
  31. }
  32. return self;
  33. }
  34. -(void)setLeftWidth:(CGFloat)leftWidth{
  35. _leftWidth = leftWidth;
  36. if (leftWidth < 50) {
  37. leftWidth = 50;
  38. }
  39. [_titlesLab setFrame:CGRectMake(10, 0, leftWidth, 17)];
  40. }
  41. -(void)setRightWith:(CGFloat)rightWith{
  42. _rightWith = rightWith;
  43. if (rightWith < 50 && rightWith != 0) {
  44. rightWith = 50;
  45. }
  46. [_descsLab setFrame:CGRectMake(CGRectGetMaxX(_titlesLab.frame) + 10, 0, rightWith, 17)];
  47. }
  48. -(void)showTitle:(NSString *)title andTitleColor:(UIColor *)titleColor andTitleFont:(UIFont *)titleFont andDescTile:(NSString *)descTitle andDescTileColor:(UIColor *)descTileColor andDescTitleFont:(UIFont *)DescTitleFont{
  49. _titlesLab.text = title;
  50. _titlesLab.textColor = titleColor;
  51. _titlesLab.font = titleFont;
  52. _titlesLab.textAlignment = NSTextAlignmentCenter;
  53. if (descTitle) _descsLab.text = descTitle;
  54. if (descTileColor) _descsLab.textColor = descTileColor;
  55. if (DescTitleFont) _descsLab.font = DescTitleFont;
  56. }
  57. @end