修复bug

This commit is contained in:
liyuhua
2023-09-25 16:02:57 +08:00
parent c4e6fae3e1
commit 48cc2d4587
37 changed files with 156 additions and 450 deletions

View File

@@ -20,19 +20,10 @@
///
@property (nonatomic,strong) UIImageView *bgImageView;
///icon
@property (nonatomic,strong) UIImageView *iconImageView;
///
@property (nonatomic,strong) NetImageView *avatImageView;
///
@property (nonatomic,strong) UILabel *titleLabel;
///
@property (nonatomic,strong) UILabel *nickLabel;
///
@property (nonatomic, strong) UILabel *descLabel;
///
@property (nonatomic, strong) UILabel *rankLabel;
///
@property(nonatomic,strong) UIButton *lookUpBtn;
@end
@implementation XPRoomAnchorRankBannerView
@@ -52,59 +43,45 @@
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.bgImageView];
[self addSubview:self.iconImageView];
[self addSubview:self.titleLabel];
[self addSubview:self.avatImageView];
[self addSubview:self.nickLabel];
[self addSubview:self.descLabel];
[self addSubview:self.rankLabel];
[self.bgImageView addSubview:self.titleLabel];
[self.bgImageView addSubview:self.lookUpBtn];
}
- (void)initSubViewConstraints {
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.centerY.mas_equalTo(self);
make.width.mas_equalTo(360);
make.height.mas_equalTo(50);
make.edges.equalTo(self);
}];
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.bgImageView).mas_offset(-14);
make.centerY.mas_equalTo(self);
make.width.mas_equalTo(61);
make.height.mas_equalTo(60);
[self.lookUpBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(-kGetScaleWidth(12));
make.width.mas_equalTo(kGetScaleWidth(60));
make.height.mas_equalTo(kGetScaleWidth(28));
make.centerY.equalTo(self.bgImageView);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.iconImageView.mas_right).mas_offset(3);
make.centerY.mas_equalTo(self.bgImageView).mas_offset(2);
}];
[self.avatImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.titleLabel.mas_right).mas_offset(3);
make.centerY.mas_equalTo(self.titleLabel);
make.width.height.mas_equalTo(22);
}];
[self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.avatImageView.mas_right).mas_offset(3);
make.centerY.mas_equalTo(self.titleLabel);
}];
[self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nickLabel.mas_right).mas_offset(3);
make.centerY.mas_equalTo(self.titleLabel);
}];
[self.rankLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.descLabel.mas_right);
make.centerY.mas_equalTo(self.titleLabel);
make.leading.mas_equalTo(kGetScaleWidth(65));
make.trailing.equalTo(self.lookUpBtn.mas_leading).mas_offset(-kGetScaleWidth(7));
make.centerY.equalTo(self.bgImageView);
}];
}
- (void)setAnchorRankInfo:(RoomHalfHourRankModel *)anchorRankInfo {
_anchorRankInfo = anchorRankInfo;
if (anchorRankInfo) {
self.avatImageView.imageUrl = _anchorRankInfo.avatar;
NSString *nick = _anchorRankInfo.nick;
if(nick.length > 4) {
nick = [NSString stringWithFormat:@"%@…", [nick substringToIndex:4]];
if(nick.length > 5) {
nick = [NSString stringWithFormat:@"%@…", [nick substringToIndex:5]];
}
self.nickLabel.text = nick;
self.descLabel.text = _anchorRankInfo.desc;
NSString *title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomAnchorRankBannerView0"),nick];
NSMutableAttributedString *titleAtt = [[NSMutableAttributedString alloc]initWithString:title attributes:@{NSFontAttributeName:kFontMedium(12),NSForegroundColorAttributeName:[UIColor whiteColor]}];
[titleAtt addAttributes:@{NSFontAttributeName:kFontMedium(12),NSForegroundColorAttributeName:UIColorFromRGB(0xF4FF48)} range:[title rangeOfString:nick]];
[titleAtt addAttributes:@{NSFontAttributeName:kFontMedium(12),NSForegroundColorAttributeName:UIColorFromRGB(0xF4FF48)} range:[title rangeOfString:YMLocalizedString(@"XPRoomAnchorRankBannerView1")]];
_titleLabel.attributedText = titleAtt;
}
}
-(void)lookUpAction{
if(self.delegate && [self.delegate respondsToSelector:@selector(xPRoomAnchorRankBannerView:rankInfo:)]){
[self.delegate xPRoomAnchorRankBannerView:self rankInfo:self.anchorRankInfo];
}
}
#pragma mark - Getters And Setters
@@ -116,65 +93,24 @@
return _bgImageView;
}
- (UIImageView *)iconImageView {
if (!_iconImageView) {
_iconImageView = [[UIImageView alloc] init];
_iconImageView.image = [UIImage imageNamed:@"anchor_hour_rank_icon"];
}
return _iconImageView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:13 weight:UIFontWeightBold];
label.textColor = [UIColor whiteColor];
label.text = YMLocalizedString(@"XPRoomAnchorRankBannerView0");
_titleLabel = label;
}
return _titleLabel;
}
- (NetImageView *)avatImageView {
if (!_avatImageView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.imageType = ImageTypeUserIcon;
_avatImageView = [[NetImageView alloc] initWithConfig:config];
_avatImageView.layer.masksToBounds = YES;
_avatImageView.layer.cornerRadius = 11;
}
return _avatImageView;
}
- (UILabel *)nickLabel {
if (!_nickLabel) {
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:13 weight:UIFontWeightBold];
label.textColor = UIColorFromRGB(0xFFFC2C);
_nickLabel = label;
- (UIButton *)lookUpBtn{
if(!_lookUpBtn){
_lookUpBtn = [UIButton new];
[_lookUpBtn setBackgroundImage:kImage(@"anchor_hour_rank_icon") forState:UIControlStateNormal];
[_lookUpBtn addTarget:self action:@selector(lookUpAction) forControlEvents:UIControlEventTouchUpInside];
}
return _nickLabel;
return _lookUpBtn;
}
- (UILabel *)descLabel {
if (!_descLabel) {
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:13 weight:UIFontWeightHeavy];
label.textColor = [UIColor whiteColor];
_descLabel = label;
}
return _descLabel;
}
- (UILabel *)rankLabel {
if (!_rankLabel) {
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:13 weight:UIFontWeightHeavy];
label.textColor = UIColorFromRGB(0xFFFC2C);
label.text = @"TOP1";
_rankLabel = label;
}
return _rankLabel;
}
@end