Files
peko-ios/YuMi/Modules/YMMonents/View/Cell/XPMonentsTopicCollectionViewCell.m
2024-07-17 17:49:33 +08:00

115 lines
3.6 KiB
Objective-C

//
// XPMonentsTopicCollectionViewCell.m
// xplan-ios
//
// Created by 冯硕 on 2022/5/18.
//
#import "XPMonentsTopicCollectionViewCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "UIImage+Utils.h"
///Model
#import "MomentsTopicModel.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.backgroundColor = [UIColor clearColor];
self.contentView.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:self.iconImageView];
[self.contentView addSubview:self.topicLabel];
// [self.contentView addSubview:self.topicImageView];
// [self.topicImageView addSubview:self.iconImageView];
// [self.topicImageView addSubview:self.topicLabel];
}
- (void)initSubViewConstraints {
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.contentView);
make.leading.mas_equalTo(14);
make.width.height.mas_equalTo(10);
}];
[self.topicLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.trailing.equalTo(self.contentView);
make.leading.equalTo(self.iconImageView.mas_trailing).mas_offset(5);
make.trailing.mas_equalTo(-5.5);
}];
// [self.topicImageView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.edges.mas_equalTo(self.contentView);
// }];
//
// [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.leading.mas_equalTo(self.topicImageView).offset(7);
// make.size.mas_equalTo(CGSizeMake(16, 16));
// make.centerY.mas_equalTo(self.topicImageView);
// }];
//
// [self.topicLabel mas_makeConstraints:^(MASConstraintMaker *make) {
// make.leading.mas_equalTo(self.iconImageView.mas_trailing).offset(2);
// make.centerY.mas_equalTo(self.topicImageView);
// }];
}
#pragma mark - Getters And Setters
- (void)setTopicInfo:(MomentsTopicModel *)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:13 weight:UIFontWeightRegular];
_topicLabel.textColor = UIColorFromRGB(0x1F1A4E);
}
return _topicLabel;
}
@end