cell里面
#import <UIKit/UIKit.h>
#import "LocalMallGoodsCommentListFrameModel.h"
NS_ASSUME_NONNULL_BEGIN
@protocol LocalMallGoodsCommentListCellDelegate <NSObject>
- (void)localMallGoodsCommentListCellBackType:(NSInteger)type backIndexPath:(NSIndexPath *)indexPath;
@end
@interface LocalMallGoodsCommentListCell : UITableViewCell
@property(nonatomic,strong)LocalMallGoodsCommentListFrameModel *frameModel;
@property(nonatomic,weak)BaseVC *parentVC;
@property(nonatomic,strong)NSIndexPath *indexPath;
@property(nonatomic,weak)id <LocalMallGoodsCommentListCellDelegate> delegate;
@end
NS_ASSUME_NONNULL_END
#import "LocalMallGoodsCommentListCell.h"
#import "LocalMallGCLCellStarView.h"
#import "LocalMallGCLCellPictureView.h"
@interface LocalMallGoodsCommentListCell ()
@property(nonatomic,strong)UIImageView *avatarIV;
@property(nonatomic,strong)UILabel *commentatorLab;
@property(nonatomic,strong)LocalMallGCLCellStarView *starView;
@property(nonatomic,strong)UILabel *goodsSpecLab;
@property(nonatomic,strong)UILabel *contentLab;
@property(nonatomic,strong)LocalMallGCLCellPictureView *pictureView;
@property(nonatomic,strong)UILabel *timeLab;
@property(nonatomic,strong)UILabel *deleteLab;
@property(nonatomic,strong)BSTCenterButton *praiseButton;
@property(nonatomic,strong)BSTCenterButton *commentButton;
@end
@implementation LocalMallGoodsCommentListCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
}
return self;
}
- (void)setFrameModel:(LocalMallGoodsCommentListFrameModel *)frameModel
{
_frameModel = frameModel;
//frame
self.avatarIV.frame = frameModel.avatarIVFrame;
self.commentatorLab.frame = frameModel.commentatorLabFrame;
self.starView.frame = frameModel.starViewFrame;
self.goodsSpecLab.frame = frameModel.goodsSpecLabFrame;
self.contentLab.frame = frameModel.contentLabFrame;
self.pictureView.frame = frameModel.pictureFrame;
self.timeLab.frame = frameModel.timeLabFrame;
self.deleteLab.frame = frameModel.deleteLabFrame;
self.deleteLab.centerY = self.timeLab.centerY;
self.praiseButton.wppImageRect = frameModel.praiseImageButtonFrame;
self.praiseButton.wppTitleRect = frameModel.praiseTitleButtonFrame;
self.praiseButton.frame = frameModel.praiseButtonFrame;
self.commentButton.wppImageRect = frameModel.commentImageButtonFrame;
self.commentButton.wppTitleRect = frameModel.commentTitleButtonFrame;
self.commentButton.frame = frameModel.commentButtonFrame;
self.praiseButton.centerY = self.timeLab.centerY;
self.commentButton.centerY = self.timeLab.centerY;
//数据
[self.avatarIV sd_setImageWithURL:frameModel.listModel.avatar.wppURL placeholderImage:[UIImage getPNGimageInBundleWithName:kDefaultHold]];
self.commentatorLab.text = frameModel.listModel.commentator;
self.starView.star = frameModel.listModel.star.integerValue;
self.goodsSpecLab.text = frameModel.listModel.goods_spec;
self.contentLab.text = frameModel.listModel.content;
self.pictureView.frameModel = frameModel;
self.timeLab.text = frameModel.listModel.create_time;
[self.commentButton setTitle:frameModel.listModel.reply_num forState:UIControlStateNormal];
[self.praiseButton setTitle:frameModel.listModel.praise_num forState:UIControlStateNormal];
self.praiseButton.selected = frameModel.listModel.is_praise.boolValue;
}
#pragma mark - click事件
- (void)clickPraiseButton:sender
{
if (self.delegate) {
[self.delegate localMallGoodsCommentListCellBackType:0 backIndexPath:self.indexPath];
}
}
- (void)clickCommentButton:sender
{
if (self.delegate) {
[self.delegate localMallGoodsCommentListCellBackType:1 backIndexPath:self.indexPath];
}
}
- (void)clickDeleteLab:sender
{
if (self.delegate) {
[self.delegate localMallGoodsCommentListCellBackType:2 backIndexPath:self.indexPath];
}
}
#pragma mark - lazy懒加载
- (UIImageView *)avatarIV
{
if (!_avatarIV) {
UIImageView *iv = [[UIImageView alloc]init];
[self.contentView addSubview:iv];
iv.contentMode = UIViewContentModeScaleAspectFill;
iv.layer.cornerRadius = 20*ADAPTER_WIDTH;
iv.layer.masksToBounds = YES;
_avatarIV = iv;
}
return _avatarIV;
}
- (UILabel *)commentatorLab
{
if (!_commentatorLab) {
UILabel *lab = [[UILabel alloc]init];
[self.contentView addSubview:lab];
lab.font = [UIFont systemFontOfSize:16*ADAPTER_WIDTH weight:UIFontWeightMedium];
lab.textColor = kColor51;
lab.textAlignment = NSTextAlignmentLeft;
lab.numberOfLines = 1;
_commentatorLab = lab;
}
return _commentatorLab;
}
- (LocalMallGCLCellStarView *)starView
{
if (!_starView) {
_starView = [[LocalMallGCLCellStarView alloc]initWithFrame:CGRectMake(0, 0, 65*ADAPTER_WIDTH, 9*ADAPTER_WIDTH)];
[self.contentView addSubview:_starView];
}
return _starView;
}
- (UILabel *)goodsSpecLab
{
if (!_goodsSpecLab) {
UILabel *lab = [[UILabel alloc]init];
[self.contentView addSubview:lab];
lab.font = [UIFont systemFontOfSize:13*ADAPTER_WIDTH weight:UIFontWeightMedium];
lab.textColor = rgba(153, 153, 153, 1);
lab.textAlignment = NSTextAlignmentLeft;
lab.numberOfLines = 1;
_goodsSpecLab = lab;
}
return _goodsSpecLab;
}
- (UILabel *)contentLab
{
if (!_contentLab) {
UILabel *lab = [[UILabel alloc]init];
[self.contentView addSubview:lab];
lab.font = [UIFont systemFontOfSize:14*ADAPTER_WIDTH weight:UIFontWeightRegular];
lab.textColor = rgba(68, 68, 68, 1);
lab.textAlignment = NSTextAlignmentLeft;
lab.numberOfLines = 0;
_contentLab = lab;
}
return _contentLab;
}
- (LocalMallGCLCellPictureView *)pictureView
{
if (!_pictureView) {
CGFloat itemWidth = (WIDTH - 81*ADAPTER_WIDTH)/3;
LocalMallGCLCellPictureView *view = [[LocalMallGCLCellPictureView alloc]initWithFrame:CGRectMake(0, 0, WIDTH - 67*ADAPTER_WIDTH, itemWidth)];
[self.contentView addSubview:view];
view.parentVC = self.parentVC;
_pictureView = view;
}
return _pictureView;
}
- (UILabel *)timeLab
{
if (!_timeLab) {
UILabel *lab = [[UILabel alloc]init];
[self addSubview:lab];
lab.font = [UIFont systemFontOfSize:13*ADAPTER_WIDTH weight:UIFontWeightRegular];
lab.textColor = rgba(85, 85, 85, 1);
lab.textAlignment = NSTextAlignmentLeft;
lab.numberOfLines = 1;
_timeLab = lab;
}
return _timeLab;
}
- (UILabel *)deleteLab
{
if (!_deleteLab) {
UILabel *lab = [[UILabel alloc]init];
[self addSubview:lab];
lab.font = [UIFont systemFontOfSize:13*ADAPTER_WIDTH weight:UIFontWeightRegular];
lab.textColor = rgba(61, 115, 227, 1);
lab.textAlignment = NSTextAlignmentLeft;
lab.numberOfLines = 1;
lab.text = @"删除";
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickDeleteLab:)];
lab.userInteractionEnabled = YES;
[lab addGestureRecognizer:tap];
_deleteLab = lab;
}
return _deleteLab;
}
- (BSTCenterButton *)praiseButton
{
if (!_praiseButton) {
BSTCenterButton *button = [BSTCenterButton buttonWithType:UIButtonTypeCustom];
[self addSubview:button];
[button setTitleColor:rgba(85, 85, 85, 1) forState:UIControlStateNormal];
button.titleLabel.font = [UIFont systemFontOfSize:13*ADAPTER_WIDTH weight:UIFontWeightRegular];
[button setImage:[UIImage getPNGimageInBundleWithName:@"comment_redHeart_gray_small"] forState:UIControlStateNormal];
[button setImage:[UIImage getPNGimageInBundleWithName:@"comment_redHeart_red_samll"] forState:UIControlStateSelected];
[button addTarget:self action:@selector(clickPraiseButton:) forControlEvents:UIControlEventTouchDown];
_praiseButton = button;
}
return _praiseButton;
}
- (BSTCenterButton *)commentButton
{
if (!_commentButton) {
BSTCenterButton *button = [BSTCenterButton buttonWithType:UIButtonTypeCustom];
[self addSubview:button];
[button setTitleColor:rgba(85, 85, 85, 1) forState:UIControlStateNormal];
button.titleLabel.font = [UIFont systemFontOfSize:13*ADAPTER_WIDTH weight:UIFontWeightRegular];
[button setImage:[UIImage getPNGimageInBundleWithName:@"comment_comment_samll"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(clickCommentButton:) forControlEvents:UIControlEventTouchDown];
_commentButton = button;
}
return _commentButton;
}
@end
网友评论