修复适配bug

This commit is contained in:
liyuhua
2024-04-19 17:26:43 +08:00
parent c638ebbc02
commit d5f595777b
8 changed files with 83 additions and 63 deletions

View File

@@ -72,18 +72,19 @@
- (void)setCandyInfo:(NSDictionary *)candyInfo {
if (candyInfo) {
CandyTreeGiftInfoModel * giftInfo = [CandyTreeGiftInfoModel modelWithDictionary:candyInfo];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
if(giftInfo.nick.length > 8){
giftInfo.nick = [NSString stringWithFormat:@"%@...",[giftInfo.nick substringToIndex:8]];
}
NSString *text = [NSString stringWithFormat:YMLocalizedString(@"XPRoomCandyGiftView0"),giftInfo.nick,giftInfo.prizeName,[NSString stringWithFormat:@" X %d", giftInfo.prizeNum]];
CGFloat fontSize = self.isMaxLargeGift ? 12 : 12;
[attribute appendAttributedString:[self createAttribute:YMLocalizedString(@"XPRoomCandyGiftView0") color:[UIColor whiteColor] fontSize:fontSize]];
[attribute appendAttributedString:[self createAttribute:giftInfo.nick color:UIColorFromRGB(0xFFE44E) fontSize:fontSize]];
[attribute appendAttributedString:[self createAttribute:YMLocalizedString(@"XPRoomCandyGiftView1") color:[UIColor whiteColor] fontSize:fontSize]];
[attribute appendAttributedString:[self createAttribute:[NSString stringWithFormat:@"\n%@",giftInfo.prizeName] color:UIColorFromRGB(0xFFE44E) fontSize:fontSize]];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithAttributedString:[self createAttribute:text color:[UIColor whiteColor] fontSize:fontSize]];
[attribute addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontSize],NSForegroundColorAttributeName:UIColorFromRGB(0xFFE44E)} range:[text rangeOfString:giftInfo.nick]];
[attribute addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontSize],NSForegroundColorAttributeName:UIColorFromRGB(0xFFE44E)} range:[text rangeOfString:giftInfo.prizeName]];
if (giftInfo.prizeNum > 1) {
[attribute appendAttributedString:[self createAttribute:[NSString stringWithFormat:@" X%d", giftInfo.prizeNum] color:[UIColor whiteColor] fontSize:fontSize]];
[attribute addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontSize],NSForegroundColorAttributeName:[UIColor whiteColor]} range:[text rangeOfString:[NSString stringWithFormat:@" X %d", giftInfo.prizeNum]]];
}
self.titleLabel.attributedText = attribute;
self.titleLabel.textAlignment = NSTextAlignmentCenter;