小说绘上架版本
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFRechargeHeaderView.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFRechargeModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFRechargeHeaderView : UIView
|
||||
|
||||
@property (nonatomic ,strong) TFRechargeModel *rechargeModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,116 @@
|
||||
//
|
||||
// TFRechargeHeaderView.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFRechargeHeaderView.h"
|
||||
|
||||
@interface TFRechargeHeaderView ()
|
||||
{
|
||||
UILabel *goldRemainLabel;
|
||||
UILabel *goldUnitLabel;
|
||||
|
||||
UILabel *subRemainLabel;
|
||||
UILabel *subUnitLabel;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFRechargeHeaderView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self createSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.backgroundColor = kColorRGB(46, 46, 48);
|
||||
|
||||
goldUnitLabel = [[UILabel alloc] init];
|
||||
goldUnitLabel.textAlignment = NSTextAlignmentCenter;
|
||||
goldUnitLabel.textColor = kColorRGB(231, 185, 117);
|
||||
goldUnitLabel.font = kMainFont;
|
||||
[self addSubview:goldUnitLabel];
|
||||
|
||||
[goldUnitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.mas_left).with.offset(kMargin);
|
||||
make.bottom.mas_equalTo(self.mas_bottom).with.offset(- kMargin);
|
||||
make.width.mas_equalTo((SCREEN_WIDTH - 2 * kMargin) / 2);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
goldRemainLabel = [[UILabel alloc] init];
|
||||
goldRemainLabel.textAlignment = NSTextAlignmentCenter;
|
||||
goldRemainLabel.textColor = kColorRGB(231, 185, 117);
|
||||
goldRemainLabel.font = kBoldFont30;
|
||||
[self addSubview:goldRemainLabel];
|
||||
|
||||
[goldRemainLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(goldUnitLabel.mas_left);
|
||||
make.bottom.mas_equalTo(goldUnitLabel.mas_top).with.offset(- kHalfMargin);
|
||||
make.width.mas_equalTo(goldUnitLabel.mas_width);
|
||||
make.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
UIView *line = [[UIView alloc] init];
|
||||
line.backgroundColor = kGrayViewColor;
|
||||
[self addSubview:line];
|
||||
|
||||
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(goldRemainLabel.mas_right);
|
||||
make.top.mas_equalTo(goldRemainLabel.mas_top);
|
||||
make.bottom.mas_equalTo(goldUnitLabel.mas_bottom);
|
||||
make.width.mas_equalTo(kCellLineHeight);
|
||||
}];
|
||||
|
||||
subUnitLabel = [[UILabel alloc] init];
|
||||
subUnitLabel.textAlignment = NSTextAlignmentCenter;
|
||||
subUnitLabel.textColor = kWhiteColor;
|
||||
subUnitLabel.font = kMainFont;
|
||||
[self addSubview:subUnitLabel];
|
||||
|
||||
[subUnitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.mas_right).with.offset(- kMargin);
|
||||
make.top.mas_equalTo(goldUnitLabel.mas_top);
|
||||
make.width.mas_equalTo(goldUnitLabel.mas_width);
|
||||
make.height.mas_equalTo(goldUnitLabel.mas_height);
|
||||
}];
|
||||
|
||||
subRemainLabel = [[UILabel alloc] init];
|
||||
subRemainLabel.textAlignment = NSTextAlignmentCenter;
|
||||
subRemainLabel.textColor = kWhiteColor;
|
||||
subRemainLabel.font = kBoldFont30;
|
||||
[self addSubview:subRemainLabel];
|
||||
|
||||
[subRemainLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(subUnitLabel.mas_right);
|
||||
make.top.mas_equalTo(goldRemainLabel.mas_top);
|
||||
make.width.mas_equalTo(subUnitLabel.mas_width);
|
||||
make.height.mas_equalTo(goldRemainLabel.mas_height);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (void)setRechargeModel:(TFRechargeModel *)rechargeModel
|
||||
{
|
||||
_rechargeModel = rechargeModel;
|
||||
|
||||
goldUnitLabel.text = rechargeModel.goldUnit?:@"";
|
||||
subUnitLabel.text = rechargeModel.silverUnit?:@"";
|
||||
|
||||
if (TFUserInfoManager.isLogin) {
|
||||
goldRemainLabel.text = [TFUtilsHelper formatStringWithInteger:rechargeModel.goldRemain];
|
||||
subRemainLabel.text = [TFUtilsHelper formatStringWithInteger:rechargeModel.silverRemain];
|
||||
} else {
|
||||
goldRemainLabel.text = @"--";
|
||||
subRemainLabel.text = @"--";
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TFRechargeViewCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFRechargeModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFRechargeViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFGoodsModel *goodsModel;
|
||||
|
||||
@property (nonatomic ,assign) BOOL cellSelected;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,165 @@
|
||||
//
|
||||
// TFRechargeViewCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFRechargeViewCell.h"
|
||||
|
||||
@interface TFRechargeViewCell ()
|
||||
{
|
||||
UIView *backView;
|
||||
|
||||
UIImageView *tagImageView;
|
||||
UILabel *tagTitleLabel;
|
||||
|
||||
UILabel *cellTitleLabel;
|
||||
UILabel *priceTitleLabel;
|
||||
UILabel *originPriceTitleLabel;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFRechargeViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
tagImageView = [[UIImageView alloc] init];
|
||||
tagImageView.hidden = YES;
|
||||
tagImageView.backgroundColor = [UIColor clearColor];
|
||||
UIImage *tagImage = [UIImage imageNamed:@"member_tag.png"];
|
||||
tagImageView.image = [tagImage resizableImageWithCapInsets:UIEdgeInsetsMake(tagImage.size.height * 0.5, tagImage.size.width * 0.5, tagImage.size.height * 0.5 - 1.0, tagImage.size.width * 0.5 - 1.0)];
|
||||
[self.contentView addSubview:tagImageView];
|
||||
|
||||
tagTitleLabel = [[UILabel alloc] init];
|
||||
tagTitleLabel.textColor = kWhiteColor;
|
||||
tagTitleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
tagTitleLabel.font = kFont10;
|
||||
tagTitleLabel.hidden = YES;
|
||||
[self.contentView addSubview:tagTitleLabel];
|
||||
|
||||
[tagTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top);
|
||||
make.height.mas_equalTo(20);
|
||||
make.width.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
|
||||
[tagImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(tagTitleLabel);
|
||||
}];
|
||||
|
||||
backView = [[UIView alloc] init];
|
||||
backView.backgroundColor = kWhiteColor;
|
||||
backView.layer.cornerRadius = 4;
|
||||
backView.layer.borderWidth = 1;
|
||||
backView.layer.borderColor = kColorRGB(243, 231, 213).CGColor;
|
||||
[self.contentView addSubview:backView];
|
||||
|
||||
[backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(tagTitleLabel.mas_left);
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
|
||||
make.top.mas_equalTo(tagTitleLabel.mas_centerY);
|
||||
make.height.mas_equalTo(80);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin).priorityLow();
|
||||
}];
|
||||
|
||||
cellTitleLabel = [[UILabel alloc] init];
|
||||
cellTitleLabel.textColor = kColorRGB(101, 101, 101);
|
||||
cellTitleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
cellTitleLabel.font = kBoldMainFont;
|
||||
[self.contentView addSubview:cellTitleLabel];
|
||||
|
||||
[cellTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(backView.mas_centerY);
|
||||
make.left.mas_equalTo(backView.mas_left).with.offset(kMargin);
|
||||
make.height.mas_equalTo(backView.mas_height).multipliedBy(0.3);
|
||||
}];
|
||||
|
||||
originPriceTitleLabel = [[UILabel alloc] init];
|
||||
originPriceTitleLabel.textColor = kColorRGB(153, 153, 153);
|
||||
originPriceTitleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
originPriceTitleLabel.numberOfLines = 0;
|
||||
originPriceTitleLabel.font = kFont10;
|
||||
[self.contentView addSubview:originPriceTitleLabel];
|
||||
|
||||
[originPriceTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(backView.mas_centerY);
|
||||
make.left.mas_equalTo(cellTitleLabel.mas_left);
|
||||
make.width.mas_equalTo(cellTitleLabel.mas_width);
|
||||
make.height.mas_equalTo(backView.mas_height).multipliedBy(0.3);
|
||||
}];
|
||||
|
||||
priceTitleLabel = [[UILabel alloc] init];
|
||||
priceTitleLabel.textColor = kColorRGB(232, 165, 72);
|
||||
priceTitleLabel.textAlignment = NSTextAlignmentRight;
|
||||
priceTitleLabel.font = kBoldMainFont;
|
||||
[self.contentView addSubview:priceTitleLabel];
|
||||
|
||||
[priceTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(backView.mas_right).with.offset(- kHalfMargin);
|
||||
make.width.mas_equalTo(120);
|
||||
make.centerY.mas_equalTo(backView.mas_centerY);
|
||||
make.height.mas_equalTo(backView.mas_height);
|
||||
}];
|
||||
|
||||
[cellTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(priceTitleLabel.mas_left).offset(-kHalfMargin);
|
||||
}];
|
||||
|
||||
[self.contentView bringSubviewToFront:tagImageView];
|
||||
[self.contentView bringSubviewToFront:tagTitleLabel];
|
||||
}
|
||||
|
||||
- (void)setGoodsModel:(TFGoodsModel *)goodsModel
|
||||
{
|
||||
_goodsModel = goodsModel;
|
||||
|
||||
if (goodsModel.tag.count > 0) {
|
||||
if ([goodsModel.tag firstObject].tab.length > 0) {
|
||||
tagImageView.hidden = NO;
|
||||
tagTitleLabel.hidden = NO;
|
||||
tagTitleLabel.text =[goodsModel.tag firstObject].tab?:@"";
|
||||
[tagTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:tagTitleLabel] + kMargin);
|
||||
}];
|
||||
}
|
||||
} else {
|
||||
tagImageView.hidden = YES;
|
||||
tagTitleLabel.hidden = YES;
|
||||
}
|
||||
|
||||
cellTitleLabel.text = goodsModel.title?:@"";
|
||||
originPriceTitleLabel.text = goodsModel.note?:@"";
|
||||
if (goodsModel.fat_price.length > 0) {
|
||||
priceTitleLabel.attributedText = [TFViewHelper resetFontWithFont:kBoldFont25 string:goodsModel.fat_price?:@"" range:NSMakeRange(1, goodsModel.fat_price.length - 1)];
|
||||
} else {
|
||||
priceTitleLabel.text = @"0";
|
||||
}
|
||||
[priceTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(priceTitleLabel.intrinsicContentSize.width);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (void)setCellSelected:(BOOL)cellSelected
|
||||
{
|
||||
_cellSelected = cellSelected;
|
||||
|
||||
if (cellSelected) {
|
||||
backView.backgroundColor = kColorRGB(255, 247, 235);
|
||||
backView.layer.borderColor = kColorRGB(223, 174, 103).CGColor;
|
||||
cellTitleLabel.textColor = kColorRGB(88, 48, 0);
|
||||
originPriceTitleLabel.textColor = kColorRGB(130, 106, 80);
|
||||
} else {
|
||||
backView.backgroundColor = kWhiteColor;
|
||||
backView.layer.borderColor = kColorRGB(243, 231, 213).CGColor;
|
||||
cellTitleLabel.textColor = kColorRGB(101, 101, 101);
|
||||
originPriceTitleLabel.textColor = kColorRGB(153, 153, 153);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user