口袋优选

KBRollingCollectionViewCell.m 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // KBRollingCollectionViewCell.m
  3. // YouHuiProject
  4. //
  5. // Created by jcymac on 2018/10/15.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBRollingCollectionViewCell.h"
  9. @implementation KBRollingCollectionViewCell
  10. -(id)initWithFrame:(CGRect)frame
  11. {
  12. self=[super initWithFrame:frame];
  13. if(self) {
  14. [self makeUI];
  15. }
  16. return self;
  17. }
  18. -(void)makeUI {
  19. [self.contentView addSubview:self.headImageView];
  20. [self.contentView addSubview:self.titleLable];
  21. [self.headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  22. make.left.mas_equalTo(0);
  23. make.centerY.mas_equalTo(self.contentView.mas_centerY);
  24. make.width.height.mas_equalTo(27);
  25. }];
  26. [self.titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.left.mas_equalTo(self.headImageView.mas_right).offset(5);
  28. make.centerY.mas_equalTo(self.contentView.mas_centerY);
  29. }];
  30. }
  31. - (UIImageView *)headImageView {
  32. if (!_headImageView) {
  33. _headImageView=[[UIImageView alloc] init];
  34. _headImageView.clipsToBounds=YES;
  35. _headImageView.layer.cornerRadius=10;
  36. _headImageView.backgroundColor=[UIColor redColor];
  37. }
  38. return _headImageView;
  39. }
  40. - (UILabel *)titleLable {
  41. if (!_titleLable) {
  42. _titleLable=[[UILabel alloc] init];
  43. _titleLable.font=[UIFont systemFontOfSize:12];
  44. _titleLable.textColor=[UIColor colorWithHexString:@"#333333"];
  45. }
  46. return _titleLable;
  47. }
  48. -(void)setModel:(KBSignInRollingUser *)model
  49. {
  50. _model=model;
  51. [self.headImageView sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:[UIImage imageNamed:@"signUserHead"]];
  52. self.titleLable.text = _model.res;
  53. [self.titleLable mas_updateConstraints:^(MASConstraintMaker *make) {
  54. make.left.mas_equalTo(self.headImageView.mas_right).offset(5);
  55. make.centerY.mas_equalTo(self.contentView.mas_centerY);
  56. }];
  57. }
  58. @end