99 lines
2.7 KiB
Objective-C
99 lines
2.7 KiB
Objective-C
//
|
|
// XPMonentsTopicCollectionViewCell.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2022/5/18.
|
|
//
|
|
|
|
#import "XPMonentsTopicCollectionViewCell.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "ThemeColor.h"
|
|
#import "UIImage+Utils.h"
|
|
///Model
|
|
#import "MonentsTopicModel.h"
|
|
|
|
@interface XPMonentsTopicCollectionViewCell ()
|
|
|
|
///背景
|
|
@property (nonatomic,strong) UIImageView *topicImageView;
|
|
///显示话题前面的#
|
|
@property (nonatomic,strong) UIImageView *iconImageView;
|
|
///显示话题
|
|
@property (nonatomic,strong) UILabel *topicLabel;
|
|
|
|
@end
|
|
|
|
@implementation XPMonentsTopicCollectionViewCell
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
[self.contentView addSubview:self.topicImageView];
|
|
[self.topicImageView addSubview:self.iconImageView];
|
|
[self.topicImageView addSubview:self.topicLabel];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.topicImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_equalTo(self.contentView);
|
|
}];
|
|
|
|
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self.topicImageView).offset(7);
|
|
make.size.mas_equalTo(CGSizeMake(25, 25));
|
|
make.centerY.mas_equalTo(self.topicImageView);
|
|
}];
|
|
|
|
[self.topicLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self.iconImageView.mas_right).offset(2);
|
|
make.centerY.mas_equalTo(self.topicImageView);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (void)setTopicInfo:(MonentsTopicModel *)topicInfo {
|
|
_topicInfo = topicInfo;
|
|
if (_topicInfo) {
|
|
self.topicLabel.text = _topicInfo.name;
|
|
}
|
|
}
|
|
|
|
- (UIImageView *)topicImageView {
|
|
if (!_topicImageView) {
|
|
_topicImageView = [[UIImageView alloc] init];
|
|
_topicImageView.userInteractionEnabled = YES;
|
|
_topicImageView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFFFCDD), UIColorFromRGB(0xDFF9FF), UIColorFromRGB(0xF4E5FF)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
|
|
_topicImageView.layer.masksToBounds = YES;
|
|
_topicImageView.layer.cornerRadius = 13;
|
|
}
|
|
return _topicImageView;
|
|
}
|
|
|
|
- (UIImageView *)iconImageView {
|
|
if (!_iconImageView) {
|
|
_iconImageView = [[UIImageView alloc] init];
|
|
_iconImageView.userInteractionEnabled = YES;
|
|
_iconImageView.image = [UIImage imageNamed:@"monents_info_topic_icon"];
|
|
}
|
|
return _iconImageView;
|
|
}
|
|
|
|
- (UILabel *)topicLabel {
|
|
if (!_topicLabel) {
|
|
_topicLabel = [[UILabel alloc] init];
|
|
_topicLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightBold];
|
|
_topicLabel.textColor = [ThemeColor mainTextColor];
|
|
}
|
|
return _topicLabel;
|
|
}
|
|
@end
|