|
|
@@ -560,7 +560,7 @@
|
|
|
}
|
|
|
|
|
|
//加等级
|
|
|
- [self toAddLevelInfoWith:plainText And:rtmEntity.user.level];
|
|
|
+ [self toAddSmallLevelInfoWith:plainText And:rtmEntity.user.level];
|
|
|
|
|
|
return plainText;
|
|
|
}
|
|
|
@@ -911,6 +911,88 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
++ (NSMutableAttributedString *)toAddSmallLevelInfoWith:(NSMutableAttributedString *)contentStr And:(NSInteger)levelNum{
|
|
|
+
|
|
|
+ NSArray *levelInfoArr = [MOSvgaSourceManage shareManager].allLevelSoureArr;
|
|
|
+ MOStoreInfo *medalInfo;
|
|
|
+ for (MOStoreInfo *object in levelInfoArr) {
|
|
|
+ if(levelNum >= object.limit){
|
|
|
+ medalInfo = object;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CGFloat levelHeight = 14.0;
|
|
|
+
|
|
|
+ if(medalInfo.res.length > 0){
|
|
|
+
|
|
|
+ //这里调整的话, 请同时调整 MOBaseLevelView
|
|
|
+ CGFloat levelWidth = MOLevelNormalWidth;
|
|
|
+ CGFloat levelLabelX = 14.0;
|
|
|
+ CGFloat levelLabexWidth = levelWidth - levelLabelX;
|
|
|
+
|
|
|
+ if(levelNum >= 100){
|
|
|
+ levelWidth = MOLevelMaxWidth;
|
|
|
+ levelLabexWidth = levelWidth - levelLabelX - 5.0;
|
|
|
+ }
|
|
|
+ else if (levelNum < 10){
|
|
|
+ levelWidth = MOLevelMixWidth;
|
|
|
+ levelLabelX = 13.0;
|
|
|
+ levelLabexWidth = levelWidth - levelLabelX;
|
|
|
+ }
|
|
|
+
|
|
|
+ UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, levelWidth, levelHeight)];
|
|
|
+ bgView.backgroundColor = [UIColor clearColor];
|
|
|
+
|
|
|
+ YYAnimatedImageView *levelImg = [[YYAnimatedImageView alloc] init];
|
|
|
+ levelImg.frame = CGRectMake(0.0, 0.0, levelWidth, levelHeight);
|
|
|
+ levelImg.contentMode = UIViewContentModeScaleAspectFit;
|
|
|
+ NSURL *url = [NSURL URLWithString:medalInfo.res];
|
|
|
+ [levelImg setImageWithURL:url placeholder:nil];
|
|
|
+ [bgView addSubview:levelImg];
|
|
|
+
|
|
|
+ UILabel *levelLabel = [[UILabel alloc] initWithFrame:CGRectMake(levelLabelX, 0, levelLabexWidth, levelHeight)];
|
|
|
+ levelLabel.font = [MOTextTools poppinsExtraBoldFont:10.0];
|
|
|
+ levelLabel.textColor = [UIColor whiteColor];
|
|
|
+ levelLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
+ levelLabel.text = [NSString stringWithFormat:@"%zd",levelNum];
|
|
|
+ [bgView addSubview:levelLabel];
|
|
|
+ CGSize viewSize = bgView.size;
|
|
|
+
|
|
|
+ NSMutableAttributedString *levelImgAttri = [NSMutableAttributedString attachmentStringWithContent:bgView contentMode:UIViewContentModeScaleAspectFit attachmentSize:viewSize alignToFont:MOTextLabelFont alignment:YYTextVerticalAlignmentCenter];
|
|
|
+ [levelImgAttri appendAttributedString:[[NSAttributedString alloc] initWithString:@" "]];
|
|
|
+
|
|
|
+ [contentStr insertAttributedString:[levelImgAttri copy] atIndex:0];
|
|
|
+
|
|
|
+ return contentStr;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ UIImage *levelImg = [MOTextTools createLevelImageViewWith:levelNum];
|
|
|
+
|
|
|
+ CGSize levelSize;
|
|
|
+ //创建一个NSTextAttachment
|
|
|
+ NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
|
|
|
+ attachment.image = levelImg;
|
|
|
+ //字体行高
|
|
|
+ UIFont *font = MOTextLabelFont;
|
|
|
+ CGFloat attachmentHeight = font.lineHeight;
|
|
|
+ CGFloat imgSizeHeight = GetParamNotZero(levelImg.size.height);
|
|
|
+ CGFloat attachmentWidth = attachmentHeight * levelImg.size.width/ imgSizeHeight;
|
|
|
+ attachment.bounds = CGRectMake(0, (font.capHeight-font.lineHeight)/2, attachmentWidth, attachmentHeight);
|
|
|
+ levelSize = CGSizeMake(attachmentWidth, attachmentHeight);
|
|
|
+
|
|
|
+ //生成NSAttributedString
|
|
|
+ NSMutableAttributedString *levelImgAttri = [NSMutableAttributedString attachmentStringWithContent:levelImg contentMode:UIViewContentModeScaleAspectFit attachmentSize:levelSize alignToFont:MOTextLabelFont alignment:YYTextVerticalAlignmentCenter];
|
|
|
+ // NSMutableAttributedString *levelImgAttri = [[NSAttributedString attributedStringWithAttachment:attachment] mutableCopy];
|
|
|
+
|
|
|
+ [levelImgAttri appendAttributedString:[[NSAttributedString alloc] initWithString:@" "]];
|
|
|
+
|
|
|
+ [contentStr insertAttributedString:[levelImgAttri copy] atIndex:0];
|
|
|
+
|
|
|
+ return contentStr;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
//增加勋章
|
|
|
+ (NSMutableAttributedString *)toAddMedalInfoWith:(NSMutableAttributedString *)contentStr And:(NSArray *)medalList{
|
|
|
|