财神随手记账

TitleLabelTopAndBottomTableViewCell.m 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // TitleLabelTopAndBottomTableViewCell.h
  3. // FoolsparadiseView
  4. //
  5. // Created by foolsparadise on 19/01/2018.
  6. // Copyright © 2018 github.com/foolsparadise All rights reserved.
  7. //
  8. #import "TitleLabelTopAndBottomTableViewCell.h"
  9. @implementation TitleLabelTopAndBottomTableViewCell
  10. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  11. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  12. if (self) {
  13. //self.contentView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
  14. [self initViews];
  15. }
  16. return self;
  17. }
  18. - (void)initViews{
  19. __weak typeof(self) weakSelf = self;
  20. self.titleLabel = [UILabel new];
  21. self.titleLabel.textAlignment = NSTextAlignmentLeft;
  22. self.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15];;
  23. self.titleLabel.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
  24. [self.titleLabel sizeToFit];
  25. [self.contentView addSubview:self.titleLabel];
  26. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.left.mas_equalTo(weakSelf.mas_left).mas_offset(10);
  28. make.top.mas_equalTo(weakSelf.mas_top).mas_offset(0);
  29. make.size.mas_equalTo(CGSizeMake(300, 30));
  30. }];
  31. self.subtitleLabel = [UILabel new];
  32. self.subtitleLabel.textAlignment = NSTextAlignmentLeft;
  33. self.subtitleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:13];;
  34. self.subtitleLabel.textColor = [UIColor colorWithRed:188/255.0 green:186/255.0 blue:186/255.0 alpha:1];
  35. [self.subtitleLabel sizeToFit];
  36. [self.contentView addSubview:self.subtitleLabel];
  37. [_subtitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.left.mas_equalTo(weakSelf.mas_left).mas_offset(10);
  39. make.top.mas_equalTo(weakSelf.mas_top).mas_offset(30);
  40. make.size.mas_equalTo(CGSizeMake(300, 26));
  41. }];
  42. }
  43. - (void)configWithTitle:(NSString *)title withSubTitle:(NSString *)subtitle
  44. {
  45. self.titleLabel.text = title;
  46. self.subtitleLabel.text = [subtitle stringByReplacingOccurrencesOfString:@"\n" withString:@""];
  47. }
  48. - (void)awakeFromNib {
  49. [super awakeFromNib];
  50. // Initialization code
  51. }
  52. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  53. [super setSelected:selected animated:animated];
  54. // Configure the view for the selected state
  55. }
  56. @end