107 lines
3.0 KiB
Objective-C
107 lines
3.0 KiB
Objective-C
//
|
|
// XPMineSettingTableViewCell.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2021/9/17.
|
|
//
|
|
|
|
#import "XPMineSettingTableViewCell.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "ThemeColor.h"
|
|
///Model
|
|
#import "XPMineSettingItemModel.h"
|
|
|
|
@interface XPMineSettingTableViewCell ()
|
|
///容器
|
|
@property (nonatomic,strong) UIStackView *stackView;
|
|
///标题
|
|
@property (nonatomic,strong) UILabel *titleLabel;
|
|
///副标题
|
|
@property (nonatomic,strong) UILabel *subTitleLabel;
|
|
///箭头
|
|
@property (nonatomic,strong) UIImageView *arrowImageView;
|
|
@end
|
|
|
|
@implementation XPMineSettingTableViewCell
|
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
|
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
self.contentView.backgroundColor = [ThemeColor appCellBackgroundColor];
|
|
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
[self.contentView addSubview:self.stackView];
|
|
|
|
[self.stackView addArrangedSubview:self.titleLabel];
|
|
[self.stackView addArrangedSubview:self.subTitleLabel];
|
|
[self.stackView addArrangedSubview:self.arrowImageView];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.mas_equalTo(self.contentView).inset(15);
|
|
make.top.bottom.mas_equalTo(self.contentView);
|
|
}];
|
|
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (void)setItemModel:(XPMineSettingItemModel *)itemModel {
|
|
_itemModel = itemModel;
|
|
self.titleLabel.text = _itemModel.title;
|
|
self.subTitleLabel.text = _itemModel.subTitle;
|
|
}
|
|
|
|
- (UIStackView *)stackView {
|
|
if (!_stackView) {
|
|
_stackView = [[UIStackView alloc] init];
|
|
_stackView.axis = UILayoutConstraintAxisHorizontal;
|
|
_stackView.distribution = UIStackViewDistributionFill;
|
|
_stackView.alignment = UIStackViewAlignmentCenter;
|
|
_stackView.spacing = 10;
|
|
}
|
|
return _stackView;
|
|
}
|
|
|
|
- (UILabel *)titleLabel {
|
|
if (!_titleLabel) {
|
|
_titleLabel = [[UILabel alloc] init];
|
|
_titleLabel.font = [UIFont systemFontOfSize:16];
|
|
_titleLabel.textColor = [ThemeColor secondTextColor];
|
|
[_titleLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
- (UILabel *)subTitleLabel {
|
|
if (!_subTitleLabel) {
|
|
_subTitleLabel = [[UILabel alloc] init];
|
|
_subTitleLabel.font = [UIFont systemFontOfSize:12];
|
|
_subTitleLabel.textColor = [ThemeColor textThirdColor];
|
|
_subTitleLabel.textAlignment = NSTextAlignmentRight;
|
|
}
|
|
return _subTitleLabel;
|
|
}
|
|
|
|
- (UIImageView *)arrowImageView {
|
|
if (!_arrowImageView) {
|
|
_arrowImageView = [[UIImageView alloc] init];
|
|
_arrowImageView.userInteractionEnabled = YES;
|
|
_arrowImageView.image = [UIImage imageNamed:@"mine_item_arrow"];
|
|
[_arrowImageView setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
|
|
[_arrowImageView setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
|
}
|
|
return _arrowImageView;
|
|
}
|
|
|
|
|
|
@end
|