123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- //
- // DRPrivilegeReferralTableViewCell.m
- // YouHuiProject
- //
- // Created by jcymac on 2018/5/21.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "DRPrivilegeReferralTableViewCell.h"
- @interface DRPrivilegeReferralTableViewCell()
- @property (strong, nonatomic) UIImageView *leftImgView;
- @property (strong, nonatomic) UILabel *rightTitle;
- @property (strong, nonatomic) UILabel *rightDesc;
- @end
- @implementation DRPrivilegeReferralTableViewCell
- + (instancetype)cellWithTableView:(UITableView *)tableView {
- static NSString *cellID = nil;
- cellID = NSStringFromClass([self class]);
- DRPrivilegeReferralTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
- if (!cell) {
- cell = [[DRPrivilegeReferralTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- return cell;
-
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- [self initUI];
- }
- return self;
- }
- - (void)initUI {
- [self.contentView addSubview:self.leftImgView];
- [self.contentView addSubview:self.rightTitle];
- [self.contentView addSubview:self.rightDesc];
-
- [self.leftImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(12);
- make.width.height.mas_equalTo(25);
- make.centerY.mas_equalTo(self.mas_centerY);
- }];
-
- [self.rightTitle mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(self.leftImgView.mas_top).mas_offset(10);
- make.left.mas_equalTo(self.leftImgView.mas_right).mas_offset(20);
- }];
-
- [self.rightDesc mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.rightTitle);
- make.top.mas_equalTo(self.rightTitle.mas_bottom).mas_offset(5);
- make.right.mas_equalTo(-10);
- }];
- }
- -(void)setModel:(DRPrivilegeReferralModel *)model{
- _model = model;
- [self.leftImgView sd_setImageWithURL:[NSURL URLWithString:model.img]];
- self.rightTitle.text = model.title;
- self.rightDesc.text = model.content;
- }
- - (UIImageView *)leftImgView {
- if (!_leftImgView) {
- _leftImgView = [[UIImageView alloc] init];
- _leftImgView.backgroundColor = [UIColor clearColor];
- }
- return _leftImgView;
- }
- - (UILabel *)rightTitle {
- if (!_rightTitle) {
- _rightTitle = [[UILabel alloc] init];
- _rightTitle.textColor = [UIColor YHColorWithHex:0x333333];
- _rightTitle.font = [UIFont systemFontOfSize:15];
- }
- return _rightTitle;
- }
- - (UILabel *)rightDesc {
- if (!_rightDesc) {
- _rightDesc = [[UILabel alloc] init];
- _rightDesc.textColor = [UIColor YHColorWithHex:0x666666];
- _rightDesc.font = [UIFont systemFontOfSize:12];
- _rightDesc.numberOfLines = 0;
- }
- return _rightDesc;
- }
- @end
|