1
This commit is contained in:
@@ -4,18 +4,19 @@
|
||||
//
|
||||
|
||||
#import "KBSkinCardCell.h"
|
||||
#import "KBMoneyBtn.h"
|
||||
|
||||
@interface KBSkinCardCell ()
|
||||
@property (nonatomic, strong) UIImageView *coverView; // 封面
|
||||
@property (nonatomic, strong) UILabel *titleLabel; // 标题
|
||||
@property (nonatomic, strong) UILabel *priceLabel; // 价格
|
||||
@property (nonatomic, strong) KBMoneyBtn *priceBtn; // 价格
|
||||
@end
|
||||
|
||||
@implementation KBSkinCardCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.contentView.backgroundColor = [UIColor whiteColor];
|
||||
self.contentView.backgroundColor = [UIColor colorWithHex:0xF8F8F8];
|
||||
self.contentView.layer.cornerRadius = 12;
|
||||
self.contentView.layer.masksToBounds = YES;
|
||||
self.contentView.layer.shadowColor = [UIColor colorWithWhite:0 alpha:0.06].CGColor;
|
||||
@@ -24,22 +25,23 @@
|
||||
|
||||
[self.contentView addSubview:self.coverView];
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
[self.contentView addSubview:self.priceLabel];
|
||||
[self.contentView addSubview:self.priceBtn];
|
||||
|
||||
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.left.right.equalTo(self.contentView);
|
||||
make.height.equalTo(self.contentView.mas_width).multipliedBy(0.75); // 4:3
|
||||
make.height.mas_equalTo(KBFit(126));
|
||||
}];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.contentView).offset(12);
|
||||
make.right.equalTo(self.contentView).offset(-12);
|
||||
make.top.equalTo(self.coverView.mas_bottom).offset(8);
|
||||
make.top.equalTo(self.coverView.mas_bottom).offset(KBFit(8));
|
||||
make.height.mas_equalTo(KBFit(20));
|
||||
}];
|
||||
|
||||
[self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
[self.priceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.titleLabel);
|
||||
make.bottom.equalTo(self.contentView).offset(-10);
|
||||
make.bottom.equalTo(self.contentView).offset(-12);
|
||||
}];
|
||||
}
|
||||
return self;
|
||||
@@ -47,7 +49,8 @@
|
||||
|
||||
- (void)configWithTitle:(NSString *)title imageURL:(NSString *)url price:(NSString *)price {
|
||||
self.titleLabel.text = title.length ? title : @"Dopamine";
|
||||
self.priceLabel.text = price.length ? price : @"20";
|
||||
[self.priceBtn setTitle:@"20" forState:UIControlStateNormal];
|
||||
|
||||
// 简化:本地展示占位色,无网络图
|
||||
self.coverView.backgroundColor = [UIColor colorWithWhite:0.92 alpha:1.0];
|
||||
}
|
||||
@@ -68,18 +71,16 @@
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightSemibold];
|
||||
_titleLabel.textColor = [UIColor colorWithHex:0x1B1F1A];
|
||||
_titleLabel.textColor = [UIColor colorWithHex:KBBlackValue];
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)priceLabel {
|
||||
if (!_priceLabel) {
|
||||
_priceLabel = [[UILabel alloc] init];
|
||||
_priceLabel.font = [UIFont systemFontOfSize:14];
|
||||
_priceLabel.textColor = [UIColor colorWithRed:0.15 green:0.72 blue:0.62 alpha:1.0];
|
||||
- (KBMoneyBtn *)priceBtn {
|
||||
if (!_priceBtn) {
|
||||
_priceBtn = [KBMoneyBtn buttonWithType:UIButtonTypeCustom];
|
||||
}
|
||||
return _priceLabel;
|
||||
return _priceBtn;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -71,7 +71,8 @@ typedef NS_ENUM(NSInteger, KBSearchSection) {
|
||||
[self.searchBarView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.equalTo(self.backButton);
|
||||
make.left.equalTo(self.backButton.mas_right).offset(12);
|
||||
make.width.mas_equalTo(315);
|
||||
// make.width.mas_equalTo(315);
|
||||
make.right.equalTo(self.view).offset(-16);
|
||||
make.height.mas_equalTo(36);
|
||||
make.right.lessThanOrEqualTo(self.topBar).offset(-16);
|
||||
}];
|
||||
@@ -301,8 +302,8 @@ typedef NS_ENUM(NSInteger, KBSearchSection) {
|
||||
CGFloat spacing = 12; // 列间距
|
||||
CGFloat w = floor((width - inset*2 - spacing) / 2.0);
|
||||
// 高度:封面 0.75w + 标题 + 价格 + 边距,近似定高
|
||||
CGFloat h = w*0.75 + 8 + 20 + 10 + 6 + 8; // 估算
|
||||
return CGSizeMake(w, h);
|
||||
// CGFloat h = w*0.75 + 8 + 20 + 10 + 6 + 8; // 估算
|
||||
return CGSizeMake(w, KBFit(197));
|
||||
}
|
||||
|
||||
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
|
||||
|
||||
Reference in New Issue
Block a user