78 lines
2.9 KiB
Mathematica
78 lines
2.9 KiB
Mathematica
|
|
//
|
||
|
|
// QXToppicDynamicTopView.m
|
||
|
|
// QXLive
|
||
|
|
//
|
||
|
|
// Created by 启星 on 2025/6/3.
|
||
|
|
//
|
||
|
|
|
||
|
|
#import "QXToppicDynamicTopView.h"
|
||
|
|
@interface QXToppicDynamicTopView()
|
||
|
|
@property (nonatomic,strong)UILabel *titleLabel;
|
||
|
|
@property (nonatomic,strong)UIImageView *topicImageView;
|
||
|
|
@property (nonatomic,strong)UIImageView *tagImageView;
|
||
|
|
@property (nonatomic,strong)UILabel *countLabel;
|
||
|
|
@property (nonatomic,strong)UILabel *contentLabel;
|
||
|
|
@end
|
||
|
|
|
||
|
|
@implementation QXToppicDynamicTopView
|
||
|
|
|
||
|
|
-(void)setModel:(QXTopicModel *)model{
|
||
|
|
_model = model;
|
||
|
|
self.titleLabel.text = model.title;
|
||
|
|
[self.topicImageView sd_setImageWithURL:[NSURL URLWithString:model.pic]];
|
||
|
|
self.countLabel.text = [NSString localizedStringWithFormat:QXText(@"%@条动态"),[NSString qx_showHotCountNum:model.count.longLongValue]];
|
||
|
|
self.contentLabel.text = model.content;
|
||
|
|
}
|
||
|
|
|
||
|
|
//- (instancetype)initWithFrame:(CGRect)frame
|
||
|
|
//{
|
||
|
|
// self = [super initWithFrame:frame];
|
||
|
|
// if (self) {
|
||
|
|
// [self initSubviews];
|
||
|
|
// }
|
||
|
|
// return self;
|
||
|
|
//}
|
||
|
|
-(instancetype)initWithModel:(QXTopicModel *)model{
|
||
|
|
self = [super init];
|
||
|
|
if (self) {
|
||
|
|
_model = model;
|
||
|
|
[self initSubviews];
|
||
|
|
}
|
||
|
|
return self;
|
||
|
|
}
|
||
|
|
|
||
|
|
-(void)initSubviews{
|
||
|
|
self.topicImageView = [[UIImageView alloc] initWithFrame:CGRectMake(16, 12, 45, 45)];
|
||
|
|
self.topicImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||
|
|
self.topicImageView.clipsToBounds = YES;
|
||
|
|
[self.topicImageView addRoundedCornersWithRadius:4];
|
||
|
|
[self addSubview:self.topicImageView];
|
||
|
|
|
||
|
|
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.topicImageView.right+7, self.topicImageView.top, SCREEN_WIDTH-self.topicImageView.right-7-16, 24)];
|
||
|
|
self.titleLabel.font = [UIFont boldSystemFontOfSize:16.f];
|
||
|
|
self.titleLabel.textColor = QXConfig.textColor;
|
||
|
|
[self addSubview:self.titleLabel];
|
||
|
|
|
||
|
|
self.tagImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"dynamic_topic_tag"]];
|
||
|
|
self.tagImageView.frame = CGRectMake(self.titleLabel.left, self.titleLabel.bottom+7, 37 , 13);
|
||
|
|
[self addSubview:self.tagImageView];
|
||
|
|
|
||
|
|
self.countLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.tagImageView.right+4, self.titleLabel.bottom+4, SCREEN_WIDTH-self.tagImageView.right-4-16, 18)];
|
||
|
|
self.countLabel.font = [UIFont systemFontOfSize:12.f];
|
||
|
|
self.countLabel.textColor = RGB16(0x999999);
|
||
|
|
[self addSubview:self.countLabel];
|
||
|
|
|
||
|
|
self.contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, self.topicImageView.bottom+12, SCREEN_WIDTH-32, 20)];
|
||
|
|
self.contentLabel.textColor = RGB16(0x666666);
|
||
|
|
self.contentLabel.font = [UIFont systemFontOfSize:12.f];;
|
||
|
|
self.contentLabel.numberOfLines = 0;
|
||
|
|
[self addSubview:self.contentLabel];
|
||
|
|
[self setModel:self.model];
|
||
|
|
|
||
|
|
[self.contentLabel sizeToFit];
|
||
|
|
self.contentLabel.frame = CGRectMake(16, self.topicImageView.bottom+12, SCREEN_WIDTH-32, self.contentLabel.height);
|
||
|
|
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, self.contentLabel.bottom+3);
|
||
|
|
|
||
|
|
}
|
||
|
|
@end
|