Files
yinmeng-ios/xplan-ios/Main/Monents/View/Cell/XPMonentsReplyMoreTableViewCell.m
2022-08-26 21:38:47 +08:00

71 lines
2.1 KiB
Objective-C

//
// XPMonentsReplyMoreTableViewCell.m
// xplan-ios
//
// Created by 冯硕 on 2022/6/23.
//
#import "XPMonentsReplyMoreTableViewCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "ThemeColor.h"
#import "XPMonentsLayoutConfig.h"
@interface XPMonentsReplyMoreTableViewCell ()
///查看更多
@property (nonatomic,strong) UILabel *moreLabel;
@end
@implementation XPMonentsReplyMoreTableViewCell
- (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.backgroundColor = [UIColor clearColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.moreLabel];
}
- (void)initSubViewConstraints {
[self.moreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.top.bottom.mas_equalTo(self.contentView);
make.left.mas_equalTo(self.contentView).offset(kMONENTS_COMMENT_REPLY_LEFT_PADDING + KMONENTS_COMMENT_REPLY_AVATAR_WIDTH + kMONENTS_COMMENT_AVATAR_NICK_PADDING);
}];
}
#pragma mark - Event Response
- (void)moreLabelTapRecognizer {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsReplyMoreTableViewCellDidClickMoreReply:)]) {
[self.delegate xPMonentsReplyMoreTableViewCellDidClickMoreReply:self];
}
}
#pragma mark - Getters And Setters
- (void)setLeftCount:(NSInteger)leftCount {
_leftCount = leftCount;
if (_leftCount) {
self.moreLabel.text = [NSString stringWithFormat:@"展开%ld条回复", _leftCount];
}
}
- (UILabel *)moreLabel {
if (!_moreLabel) {
_moreLabel = [[UILabel alloc] init];
_moreLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightBold];
_moreLabel.textColor = [ThemeColor appEmphasizeColor];
_moreLabel.userInteractionEnabled = YES;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(moreLabelTapRecognizer)];
[_moreLabel addGestureRecognizer:tap];
}
return _moreLabel;
}
@end