From b4e1288a9b63eb820e9c9489c56aac4bf6b31067 Mon Sep 17 00:00:00 2001 From: Davin <591807572@qq.com> Date: 星期三, 18 十二月 2024 14:34:16 +0800 Subject: [PATCH] feature 图片资源更新 --- EZSDK/EZSDK/EZ/TempPassword/Views/HDLEZVideoDoorMsgCell.m | 134 ++++++++++++++++++++++++++++++++------------ 1 files changed, 96 insertions(+), 38 deletions(-) diff --git a/EZSDK/EZSDK/EZ/TempPassword/Views/HDLEZVideoDoorMsgCell.m b/EZSDK/EZSDK/EZ/TempPassword/Views/HDLEZVideoDoorMsgCell.m index 8c7c701..ef8df2c 100644 --- a/EZSDK/EZSDK/EZ/TempPassword/Views/HDLEZVideoDoorMsgCell.m +++ b/EZSDK/EZSDK/EZ/TempPassword/Views/HDLEZVideoDoorMsgCell.m @@ -10,9 +10,10 @@ @interface HDLEZVideoDoorMsgCell () @property (strong, nonatomic) UILabel *messageTitle; -@property (strong, nonatomic) UILabel *statusLabel; +//@property (strong, nonatomic) UILabel *statusLabel; @property (strong, nonatomic) UILabel *timeLabel; @property (strong, nonatomic) UIImageView *messageImageView; +@property (strong, nonatomic) UIView *separatorLine; @end @@ -28,54 +29,100 @@ - (void)createSubviews { self.contentView.backgroundColor = UIColor.whiteColor; [self.contentView addSubview:self.messageTitle]; - [self.contentView addSubview:self.statusLabel]; +// [self.contentView addSubview:self.statusLabel]; [self.contentView addSubview:self.timeLabel]; [self.contentView addSubview:self.messageImageView]; + [self.contentView addSubview:self.separatorLine]; [self.messageTitle mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self.contentView.mas_top).offset(16.); + make.top.mas_equalTo(self.contentView.mas_top).offset(24.); make.left.mas_equalTo(self.contentView.mas_left).offset(16.); - make.height.mas_equalTo(22); + make.right.mas_lessThanOrEqualTo(self.messageImageView.mas_left).offset(-16.); }]; - [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self.messageTitle.mas_bottom).offset(10.); - make.left.mas_equalTo(self.messageTitle.mas_left); - make.width.mas_equalTo(50); - make.height.mas_equalTo(30); - }]; +// [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) { +// make.top.mas_equalTo(self.messageTitle.mas_top).offset(0.); +// make.left.mas_equalTo(self.messageTitle.mas_right).offset(8.); +// make.right.mas_lessThanOrEqualTo(self.messageImageView.mas_left).offset(-8.); +// make.width.mas_equalTo(40); +// make.height.mas_equalTo(20); +// }]; [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.messageTitle.mas_bottom).offset(4.); make.left.mas_equalTo(self.messageTitle.mas_left); - make.bottom.mas_equalTo(self.messageImageView.mas_bottom); - make.right.mas_equalTo(self.messageTitle.mas_right); - make.height.mas_equalTo(22); + make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-12.); + make.height.mas_equalTo(17); }]; [self.messageImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self.contentView.mas_top).offset(16.); - make.left.mas_equalTo(self.messageTitle.mas_right).offset(10.); - make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-16.); make.right.mas_equalTo(self.contentView.mas_right).offset(-16.); - make.width.mas_equalTo(self.messageImageView.mas_height).multipliedBy(5/3.); + make.centerY.mas_equalTo(self.contentView.mas_centerY); + make.width.mas_equalTo(72.); + make.height.mas_equalTo(41.); + }]; + + [self.separatorLine mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.messageTitle.mas_left); + make.bottom.mas_equalTo(self.contentView.mas_bottom); + make.right.mas_equalTo(self.messageImageView.mas_right); + make.height.mas_equalTo(0.5); }]; } #pragma mark - PublishMethod -- (void)configMessageInfoWithTitle:(NSString *)title deviceStatus:(NSString *)deviceStatus messageTime:(NSString *)time messageImage:(NSString *)messageUrl { - if (title && title.length > 0) { - self.messageTitle.text = title; - } +- (void)configMessageInfoWithTitle:(NSString *)title deviceStatus:(NSString *)deviceStatus messageTime:(NSString *)time messageImage:(NSString *)messageUrl { + if (deviceStatus && deviceStatus.length > 0) { - self.statusLabel.text = deviceStatus; + NSMutableAttributedString *abs = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ ", title]]; + UIImage *image = [UIImage imageNamed:([deviceStatus isEqualToString:@"宸叉帴"] ? @"hdl_ez_msg_answer" : @"hdl_ez_msg_no_answer")]; + NSTextAttachment *attach = [[NSTextAttachment alloc] init]; + attach.image = image; + NSAttributedString *imageStr = [NSAttributedString attributedStringWithAttachment:attach]; + [abs appendAttributedString:imageStr]; + [abs addAttribute:NSBaselineOffsetAttributeName value:@(-5) range:NSMakeRange(title.length + 2, 1)]; // +2鏄�傞厤绌烘牸 + self.messageTitle.attributedText = abs; + } else { + if (title && title.length > 0) { + self.messageTitle.text = title; + } } + + +// if (deviceStatus && deviceStatus.length > 0) { +// +// +// +// self.statusLabel.text = deviceStatus; +// [self.statusLabel mas_updateConstraints:^(MASConstraintMaker *make) { +// make.width.mas_equalTo(40.); +// }]; +// self.statusLabel.backgroundColor = [deviceStatus isEqualToString:@"宸叉帴"] ? HDLEZHEXCOLOR(0x00C22D, 1.) : HDLEZHEXCOLOR(0xFF4747, 1.); +// } else { +// [self.statusLabel mas_updateConstraints:^(MASConstraintMaker *make) { +// make.width.mas_equalTo(0.); +// }]; +// } + if (time && time.length > 0) { self.timeLabel.text = time; } if (messageUrl && messageUrl.length > 0) { - NSLog(@"#######cell image url:%@", messageUrl); - [self.messageImageView sd_setImageWithURL:[NSURL URLWithString:messageUrl] placeholderImageScale:[UIImage imageNamed:@""]]; + [self.messageImageView sd_setImageWithURL:[NSURL URLWithString:messageUrl] placeholderImageScale:[UIImage imageNamed:@"hdl_ez_msg_placeholder"]]; + [self.messageImageView mas_updateConstraints:^(MASConstraintMaker *make) { + make.right.mas_equalTo(self.contentView.mas_right).offset(-16.); + make.width.mas_equalTo(72.); + }]; + } else { + [self.messageImageView mas_updateConstraints:^(MASConstraintMaker *make) { + make.right.mas_equalTo(self.contentView.mas_right).offset(0.); + make.width.mas_equalTo(0.); + }]; } +} + +- (void)showSpearator:(BOOL)isShow { + self.separatorLine.hidden = !isShow; } #pragma mark - Getter @@ -84,28 +131,29 @@ _messageTitle=[[UILabel alloc] init]; _messageTitle.font = HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_14); _messageTitle.textColor=HDLEZ_COLOR_TITLE_BLACK; + _messageTitle.lineBreakMode = NSLineBreakByTruncatingMiddle; + _messageTitle.numberOfLines = 2; } return _messageTitle; } -- (UILabel *)statusLabel { - if (!_statusLabel) { - _statusLabel=[[UILabel alloc] init]; - _statusLabel.font = HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_12); - _statusLabel.textColor = HDLEZ_COLOR_TEXT_LIGHT_GRAY; - _statusLabel.layer.cornerRadius = 5; - _statusLabel.layer.borderColor = HDLEZ_COLOR_TEXT_GRAY.CGColor; - _statusLabel.clipsToBounds = YES; - } - return _statusLabel; -} +//- (UILabel *)statusLabel { +// if (!_statusLabel) { +// _statusLabel=[[UILabel alloc] init]; +// _statusLabel.font = HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_12); +// _statusLabel.textColor = HDLEZ_COLOR_TEXT_WHITE; +// _statusLabel.textAlignment = NSTextAlignmentCenter; +// _statusLabel.layer.cornerRadius = 4; +// _statusLabel.clipsToBounds = YES; +// } +// return _statusLabel; +//} - (UILabel *)timeLabel { if (!_timeLabel) { _timeLabel=[[UILabel alloc] init]; _timeLabel.font = HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_12); - _timeLabel.textColor=HDLEZ_COLOR_TEXT_GRAY; - _timeLabel.textAlignment = NSTextAlignmentRight; + _timeLabel.textColor=HDLEZ_COLOR_TEXT_LIGHT_GRAY; } return _timeLabel; } @@ -113,10 +161,20 @@ - (UIImageView *)messageImageView { if (!_messageImageView) { _messageImageView = [[UIImageView alloc] init]; + _messageImageView.contentMode = UIViewContentModeScaleAspectFill; _messageImageView.backgroundColor = HDLEZ_COLOR_TEXT_LIGHT_GRAY; - + _messageImageView.layer.cornerRadius = 4; + _messageImageView.clipsToBounds = YES; } return _messageImageView; } +- (UIView *)separatorLine { + if (!_separatorLine) { + _separatorLine = [[UIView alloc] init]; + _separatorLine.backgroundColor = HDLEZ_COLOR_BACKGROUND_LINE; + } + return _separatorLine; +} + @end -- Gitblit v1.8.0