123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- //
- // XYPersinalContentOpenVipTableViewCell.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/4/10.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYPersinalContentOpenVipTableViewCell.h"
- #import "XYPersonalCenterListModel.h"
- @interface XYPersinalContentOpenVipTableViewCell ()
- @property (nonatomic, readwrite, strong) UIView *infoView;
- @property (nonatomic, readwrite, strong) UIImageView *bgImageView;
- @property (nonatomic, readwrite, strong) UIImageView *titleImageView;
- @property (nonatomic, readwrite, strong) UILabel *titleLabel;
- @property (nonatomic, readwrite, strong) UIImageView *moreImageView;
- @property (nonatomic, readwrite, strong) UILabel *contentLabel;
- @end
- @implementation XYPersinalContentOpenVipTableViewCell
- #pragma mark - Public Method
- + (instancetype)cellWithTableView:(UITableView *)tableView {
- static NSString * const cellId = @"XYPersinalContentOpenVipTableViewCell";
- XYPersinalContentOpenVipTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
- if (cell == nil) {
- cell = [[XYPersinalContentOpenVipTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- return cell;
- }
- - (void)configureModel:(XYPersonalCenterListModel *)model {
- self.titleImageView.image = ImageNamed(model.iconName);
- self.titleLabel.text = model.title;
- self.contentLabel.text = model.content;
- self.moreImageView.hidden = !model.isShowMoreImage;
- }
- - (void)setIndexPath:(NSIndexPath *)indexPath rowsInSection:(NSInteger)rows {
- }
- #pragma mark - 初始化
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
-
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- // 初始化
- [self _setup];
-
- // 创建自控制器
- [self _setupSubViews];
-
- // 布局子控件
- [self _makeSubViewsConstraints];
- }
- return self;
- }
- #pragma mark - 事件处理Or辅助方法
- #pragma mark - Private Method
- - (void)_setup{
- self.backgroundColor = UIColor.whiteColor;
- }
- #pragma mark - 创建子控件
- - (void)_setupSubViews{
- [self.contentView addSubview:self.infoView];
- [self.infoView addSubview:self.bgImageView];
- [self.infoView addSubview:self.titleImageView];
- [self.infoView addSubview:self.titleLabel];
- [self.infoView addSubview:self.moreImageView];
- [self.infoView addSubview:self.contentLabel];
- }
- #pragma mark - 布局子控件
- - (void)_makeSubViewsConstraints{
- [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView);
- make.right.equalTo(self.contentView);
- make.top.equalTo(self.contentView);
- make.bottom.equalTo(self.contentView);
- }];
- [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self.infoView);
- }];
- [self.titleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.infoView).offset(20.0f);
- make.centerY.equalTo(self.infoView);
- make.width.equalTo(@20.0f);
- make.height.equalTo(@18.0f);
- }];
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.titleImageView.mas_right).offset(6.0f);
- make.centerY.equalTo(self.infoView);
- make.height.equalTo(@21.0f);
- }];
- [self.moreImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.infoView).offset(-20.0f);
- make.centerY.equalTo(self.infoView);
- make.width.height.equalTo(@13.0f);
- }];
- [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.moreImageView.mas_left).offset(-8.0f);
- make.centerY.equalTo(self.infoView);
- }];
-
- [self.infoView addViewBorder:Color_Clear redian:8];
- }
- - (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
- }
- - (UIView *)infoView {
- if (!_infoView) {
- _infoView = [UIView new];
- _infoView.backgroundColor = Color_Clear;
- }
- return _infoView;
- }
- - (UIImageView *)bgImageView {
- if (!_bgImageView) {
- _bgImageView = [UIImageView new];
- _bgImageView.image = ImageNamed(@"icon_my_novip_bg");
- }
- return _bgImageView;
- }
- - (UIImageView *)titleImageView {
- if (!_titleImageView) {
- _titleImageView = [UIImageView new];
- }
- return _titleImageView;
- }
- - (UILabel *)titleLabel {
- if (!_titleLabel) {
- _titleLabel = [UILabel createLabelTextColor:ColorFromHexString(@"#FDE3A6") fount:Font_B(15)];
- }
- return _titleLabel;
- }
- - (UIImageView *)moreImageView {
- if (!_moreImageView) {
- _moreImageView = [UIImageView new];
- _moreImageView.image = ImageNamed(@"icon_my_vip_more");
- }
- return _moreImageView;
- }
- - (UILabel *)contentLabel {
- if (!_contentLabel) {
- _contentLabel = [UILabel createLabelTextColor:ColorFromHexString(@"#FDE3A6") fount:Font_B(12)];
- _contentLabel.textAlignment = NSTextAlignmentRight;
- }
- return _contentLabel;
- }
- @end
|