财神随手记账

ImageAndTitleLabelTableViewCell.m 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //
  2. // ImageAndTitleLabelTableViewCell.m
  3. // FoolsparadiseView
  4. //
  5. // Created by foolsparadise on 19/01/2018.
  6. // Copyright © 2018 github.com/foolsparadise All rights reserved.
  7. //
  8. #import "ImageAndTitleLabelTableViewCell.h"
  9. @implementation ImageAndTitleLabelTableViewCell
  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.titleimageView = [UIImageView new];
  21. [self.contentView addSubview:self.titleimageView];
  22. [_titleimageView mas_makeConstraints:^(MASConstraintMaker *make) {
  23. make.left.mas_equalTo(weakSelf.mas_left).mas_offset(10);
  24. make.top.mas_equalTo(weakSelf.mas_top).mas_offset(8);
  25. make.size.mas_equalTo(CGSizeMake(40, 40));
  26. }];
  27. self.titleLabel = [UILabel new];
  28. self.titleLabel.textAlignment = NSTextAlignmentLeft;
  29. self.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15];;
  30. self.titleLabel.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
  31. [self.titleLabel sizeToFit];
  32. [self.contentView addSubview:self.titleLabel];
  33. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.left.mas_equalTo(weakSelf.mas_left).mas_offset(10+40+10);
  35. make.top.mas_equalTo(weakSelf.mas_top).mas_offset(8);
  36. make.size.mas_equalTo(CGSizeMake(300, 40));
  37. }];
  38. }
  39. - (void)configWithTitle:(NSString *)title withTitleImageName:(NSString *)ImageName
  40. {
  41. self.titleLabel.text = title;
  42. self.titleimageView.image = [UIImage imageNamed:ImageName];
  43. }
  44. - (void)awakeFromNib {
  45. [super awakeFromNib];
  46. // Initialization code
  47. }
  48. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  49. [super setSelected:selected animated:animated];
  50. // Configure the view for the selected state
  51. }
  52. @end