123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- //
- // YOUPAIHROldHomeCollectionCell.m
- // VQU
- //
- // Created by 肖浩然的mac on 2021/9/28.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAIHROldHomeCollectionCell.h"
- @interface YOUPAIHROldHomeCollectionCell()
- @property (nonatomic,strong)UIImageView *youpaipimageV;
- @property (nonatomic,strong)UIView *youpaipstatusView;
- @property (nonatomic,strong)UIView *youpaipstatusDotView;
- @property (nonatomic,strong)UILabel *youpaipstatusLab;
- @property (nonatomic,strong)UILabel *youpaipnameLab;
- @property (nonatomic,strong)UILabel *signLabel;
- @end
- @implementation YOUPAIHROldHomeCollectionCell
- static NSString* HKHomeCellID = @"YOUPAIHROldHomeCollectionCell";
- + (instancetype)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
- YOUPAIHROldHomeCollectionCell *cell = (YOUPAIHROldHomeCollectionCell *)[collectionView dequeueReusableCellWithReuseIdentifier:HKHomeCellID forIndexPath:indexPath];
- return cell;
- }
- -(id)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- if (self) {
- [self youpaifsetupUI];
- }
- return self;
- }
- - (void)youpaifsetupUI{
- self.contentView.layer.cornerRadius = 5;
- self.contentView.layer.masksToBounds = YES;
- self.youpaipimageV = [[UIImageView alloc] init];
- [self.contentView addSubview:self.youpaipimageV];
- [self.youpaipimageV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.mas_equalTo(0);
- }];
- self.youpaipimageV.backgroundColor = [LCTools getBkgRandomColor];
- self.youpaipimageV.contentMode = UIViewContentModeScaleAspectFill;
-
-
- UIView *statusView = [[UIView alloc] init];
- self.youpaipstatusView = statusView;
- [self.youpaipimageV addSubview:statusView];
- [statusView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-5);
- make.width.mas_equalTo(50);
- make.top.mas_equalTo(5);
- make.height.mas_equalTo(16);
- }];
- statusView.layer.cornerRadius = 8;
- statusView.layer.masksToBounds = YES;
- statusView.backgroundColor = HexColorFromRGBA(0x000000,0.37);
-
- self.youpaipstatusDotView = [[UIView alloc] init];
- [statusView addSubview:self.youpaipstatusDotView];
- [self.youpaipstatusDotView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(4);
- make.centerY.mas_equalTo(0);
- make.size.mas_equalTo(CGSizeMake(6, 6));
- }];
- self.youpaipstatusDotView.layer.cornerRadius = 3;
- self.youpaipstatusDotView.layer.masksToBounds = YES;
-
- self.youpaipstatusLab = [[UILabel alloc]init];
- [self.youpaipstatusView addSubview:self.youpaipstatusLab];
- [self.youpaipstatusLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.youpaipstatusDotView.mas_right).offset(2);
- make.centerY.mas_equalTo(0);
- make.height.mas_equalTo(16);
- }];
- self.youpaipstatusLab.textColor = HexColorFromRGB(0xFFFFFF);
- self.youpaipstatusLab.textAlignment = NSTextAlignmentCenter;
- self.youpaipstatusLab.font = LCFont(9);
-
- UIView *footerV = [[UIView alloc] init];
- CAGradientLayer *gradientLayerBot = [LCTools getGradientLayerWithSize:footerV.mj_size twoColors:@[[[UIColor blackColor] colorWithAlphaComponent:0.0f],[[UIColor blackColor] colorWithAlphaComponent:0.3f]] gradientType:GradientTopToBottom];
- [footerV.layer addSublayer:gradientLayerBot];
- [self.contentView addSubview:footerV];
- [footerV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.offset(0.0f);
- make.bottom.mas_equalTo(0);
- make.height.offset(49.0f);
- }];
-
- self.youpaipnameLab = [[UILabel alloc]init];
- self.youpaipnameLab.textColor = HexColorFromRGB(0xFFFFFF);
- self.youpaipnameLab.textAlignment = NSTextAlignmentLeft;
- self.youpaipnameLab.font = LCBoldFont(14);
- [footerV addSubview:self.youpaipnameLab];
- [self.youpaipnameLab makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(10.0f);
- make.bottom.offset(-20.0f);
- make.height.equalTo(@17);
- }];
- //个性签名
- UILabel *signLabel = [UILabel new];
- self.signLabel = signLabel;
- [footerV addSubview:signLabel];
- [signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10.0f);
- make.right.mas_equalTo(-10.0f);
- make.top.mas_equalTo(self.youpaipnameLab.mas_bottom).offset(5);
- make.height.mas_equalTo(12);
- }];
- signLabel.font = [UIFont systemFontOfSize:12];
- // signLabel.text = @"好看的皮囊 有趣的灵魂";
- signLabel.lineBreakMode = NSLineBreakByTruncatingTail;
- signLabel.textColor = [UIColor whiteColor];
- self.clipsToBounds = YES;
- }
- - (void)setYoupaiphomeListModel:(YOUPAILCHomeListModel *)homeListModel{
- _youpaiphomeListModel = homeListModel;
- [self.youpaipimageV sd_setImageWithURL:[[LCTools getImageUrlWithAddress:homeListModel.youpaipcover] urlWithImageScale:60] placeholderImage:nil];
- self.youpaipstatusLab.text = homeListModel.youpaipAddnewMsg;
- self.signLabel.text = homeListModel.sign;
- CGFloat width = [LCTools widthWithString:homeListModel.youpaipAddnewMsg withFont:LCFont(9)]+15;
- [self.youpaipstatusView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-5);
- make.width.mas_equalTo(width);
- make.top.mas_equalTo(5);
- make.height.mas_equalTo(16);
- }];
-
-
- self.youpaipstatusDotView.backgroundColor = kColors(homeListModel.youpaipAddnewColor);
-
- [self youpaifsetupShadowWithText:homeListModel.youpaipnickname view:self.youpaipnameLab];
-
- }
- - (void)youpaifsetupShadowWithText:(NSString *)text view:(UILabel *)view{
- NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:text];
- NSShadow *shadow = [[NSShadow alloc]init];
- // shadow.shadowBlurRadius = 1.0;
- shadow.shadowOffset = CGSizeMake(1, 1.5f);
- shadow.shadowColor = [HexColorFromRGB(0x000000) colorWithAlphaComponent:0.2f];
- [attributedString addAttribute:NSShadowAttributeName value:shadow range:NSMakeRange(0, text.length)];
- view.attributedText = attributedString;
- }
- @end
|