GuiZuRightsCollectCell.m 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // GuiZuRightsCollectCell.m
  3. // BuguLive
  4. //
  5. // Created by bugu on 2019/12/2.
  6. // Copyright © 2019 xfg. All rights reserved.
  7. //
  8. #import "GuiZuRightsCollectCell.h"
  9. @interface GuiZuRightsCollectCell ()
  10. @property(nonatomic, strong) UIImageView *iconImageView;
  11. @property(nonatomic, strong) UILabel *nameLabel;
  12. @end
  13. @implementation GuiZuRightsCollectCell
  14. - (instancetype)initWithFrame:(CGRect)frame {
  15. self = [super initWithFrame:frame];
  16. if (self) {
  17. [self initUI];
  18. }
  19. return self;
  20. }
  21. - (void)initUI{
  22. _nameLabel = ({
  23. UILabel * label = [[UILabel alloc]init];
  24. label.textColor = [UIColor colorWithHexString:@"#666666"];
  25. label.font = [UIFont systemFontOfSize:14];
  26. label.text = ASLocalizedString(@"玄铁身份");
  27. label;
  28. });
  29. _iconImageView = ({
  30. UIImageView *imageView = [[UIImageView alloc] init];
  31. imageView.image = [UIImage imageNamed:@"身份-选中"];
  32. imageView;
  33. });
  34. [self addSubview:_iconImageView];
  35. [self addSubview:_nameLabel];
  36. }
  37. - (void)layoutSubviews {
  38. [super layoutSubviews];
  39. [_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.top.mas_equalTo(5);
  41. make.centerX.equalTo(self);
  42. make.size.mas_equalTo(kRealValue(46));
  43. }];
  44. [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.top.equalTo(_iconImageView.mas_bottom).offset(2);
  46. make.centerX.equalTo(_iconImageView);
  47. }];
  48. }
  49. - (void)setModel:(GuiZuRightsModel *)model{
  50. _nameLabel.text = model.name;
  51. _iconImageView.image = [UIImage imageNamed:model.image];
  52. _iconImageView.highlightedImage = [UIImage imageNamed:model.imageSelected];
  53. _iconImageView.highlighted = model.has;
  54. }
  55. @end