127 lines
4.4 KiB
Objective-C
127 lines
4.4 KiB
Objective-C
//
|
|
// KBVipReviewItemCell.m
|
|
// keyBoard
|
|
//
|
|
// 中文注释:简单的好评卡片,顶部头像/昵称,下面 5 个爱心图标,再下一行一段文案。
|
|
//
|
|
|
|
#import "KBVipReviewItemCell.h"
|
|
|
|
@interface KBVipReviewItemCell ()
|
|
@property (nonatomic, strong) UIView *cardView;
|
|
@property (nonatomic, strong) UIImageView *avatarView;
|
|
@property (nonatomic, strong) UILabel *nameLabel;
|
|
@property (nonatomic, strong) UIStackView *heartsStack;
|
|
@property (nonatomic, strong) UILabel *contentLabel;
|
|
@end
|
|
|
|
@implementation KBVipReviewItemCell
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
if (self = [super initWithFrame:frame]) {
|
|
self.contentView.backgroundColor = UIColor.clearColor;
|
|
|
|
[self.contentView addSubview:self.cardView];
|
|
[self.cardView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self.contentView);
|
|
}];
|
|
|
|
[self.cardView addSubview:self.avatarView];
|
|
[self.cardView addSubview:self.nameLabel];
|
|
[self.cardView addSubview:self.heartsStack];
|
|
[self.cardView addSubview:self.contentLabel];
|
|
|
|
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.top.equalTo(self.cardView).offset(12);
|
|
make.width.height.mas_equalTo(28);
|
|
}];
|
|
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerY.equalTo(self.avatarView);
|
|
make.left.equalTo(self.avatarView.mas_right).offset(8);
|
|
make.right.lessThanOrEqualTo(self.cardView).offset(-12);
|
|
}];
|
|
[self.heartsStack mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(self.avatarView);
|
|
make.top.equalTo(self.avatarView.mas_bottom).offset(8);
|
|
}];
|
|
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(self.avatarView);
|
|
make.right.equalTo(self.cardView).offset(-12);
|
|
make.top.equalTo(self.heartsStack.mas_bottom).offset(6);
|
|
make.bottom.lessThanOrEqualTo(self.cardView).offset(-12);
|
|
}];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)layoutSubviews {
|
|
[super layoutSubviews];
|
|
self.cardView.layer.cornerRadius = 12;
|
|
self.cardView.layer.masksToBounds = YES;
|
|
}
|
|
|
|
- (void)configWithName:(NSString *)name text:(NSString *)text {
|
|
self.nameLabel.text = name.length ? name : @"User";
|
|
self.contentLabel.text = text.length ? text : @"I highly recommend this app.";
|
|
}
|
|
|
|
#pragma mark - Lazy
|
|
- (UIView *)cardView {
|
|
if (!_cardView) {
|
|
_cardView = [UIView new];
|
|
_cardView.backgroundColor = [UIColor whiteColor];
|
|
}
|
|
return _cardView;
|
|
}
|
|
- (UIImageView *)avatarView {
|
|
if (!_avatarView) {
|
|
_avatarView = [UIImageView new];
|
|
_avatarView.backgroundColor = [UIColor colorWithWhite:0.92 alpha:1.0];
|
|
_avatarView.layer.cornerRadius = 14;
|
|
_avatarView.layer.masksToBounds = YES;
|
|
}
|
|
return _avatarView;
|
|
}
|
|
- (UILabel *)nameLabel {
|
|
if (!_nameLabel) {
|
|
_nameLabel = [UILabel new];
|
|
_nameLabel.textColor = [UIColor colorWithHex:KBBlackValue];
|
|
_nameLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightSemibold];
|
|
_nameLabel.text = @"Sdsd666";
|
|
}
|
|
return _nameLabel;
|
|
}
|
|
- (UIStackView *)heartsStack {
|
|
if (!_heartsStack) {
|
|
_heartsStack = [[UIStackView alloc] init];
|
|
_heartsStack.axis = UILayoutConstraintAxisHorizontal;
|
|
_heartsStack.spacing = 4;
|
|
_heartsStack.alignment = UIStackViewAlignmentCenter;
|
|
_heartsStack.distribution = UIStackViewDistributionFillProportionally;
|
|
for (int i = 0; i < 1; i++) {
|
|
UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pay_5aixin_icon"]];
|
|
iv.contentMode = UIViewContentModeScaleAspectFit;
|
|
[iv mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(10);
|
|
make.width.mas_equalTo(77);
|
|
|
|
}];
|
|
[_heartsStack addArrangedSubview:iv];
|
|
}
|
|
}
|
|
return _heartsStack;
|
|
}
|
|
- (UILabel *)contentLabel {
|
|
if (!_contentLabel) {
|
|
_contentLabel = [UILabel new];
|
|
_contentLabel.textColor = [UIColor colorWithWhite:0.25 alpha:1.0];
|
|
_contentLabel.font = [UIFont systemFontOfSize:12];
|
|
_contentLabel.numberOfLines = 2;
|
|
_contentLabel.text = @"I Highly Recommend This App. It Taught Me How To Chat";
|
|
}
|
|
return _contentLabel;
|
|
}
|
|
|
|
@end
|
|
|