Преглед на файлове

[*] 进场条UI 富文本 组建调整

yanxuyao преди 5 месеца
родител
ревизия
be3c4dc212
променени са 2 файла, в които са добавени 65 реда и са изтрити 7 реда
  1. 64 6
      MiMoLive/MiMoLive/Global/MOTextTools.m
  2. 1 1
      MiMoLive/Podfile.lock

+ 64 - 6
MiMoLive/MiMoLive/Global/MOTextTools.m

@@ -556,11 +556,11 @@
     
     //加vip
     if(rtmEntity.user.vip.type > 0){
-        [self toAddVipInfoWith:plainText And:rtmEntity.user.vip.type];
+        [self toAddSmallVipInfoWith:plainText And:rtmEntity.user.vip.type AndHeight:14.0];
     }
     
     //加等级
-    [self toAddSmallLevelInfoWith:plainText And:rtmEntity.user.level];
+    [self toAddSmallLevelInfoWith:plainText And:rtmEntity.user.level AndHeight:14.0];
     
     return plainText;
 }
@@ -832,6 +832,61 @@
     return contentStr;
 }
 
++ (NSMutableAttributedString *)toAddSmallVipInfoWith:(NSMutableAttributedString *)contentStr And:(NSInteger)vipType AndHeight:(CGFloat)viewHeight{
+    
+    CGFloat theBaseViewHeight = 14;
+    if(viewHeight > 0){
+        theBaseViewHeight = viewHeight;
+    }
+    
+    if(vipType != 0){
+        //VIP 对象
+        MOBaseVips *vipObject = [[MOSvgaSourceManage shareManager] toGetTheVipObjectWith:vipType];
+        if(vipObject){
+            UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, theBaseViewHeight, theBaseViewHeight)];
+            bgView.backgroundColor = [UIColor clearColor];
+            YYAnimatedImageView *medalImg = [[YYAnimatedImageView alloc] init];
+            medalImg.frame = CGRectMake(0.0, 0.0, theBaseViewHeight, theBaseViewHeight);
+            medalImg.contentMode = UIViewContentModeScaleAspectFit;
+            
+            NSString *urlStr = vipObject.thumbnail;
+            NSURL *url = [NSURL URLWithString:urlStr];
+            [medalImg setImageWithURL:url placeholder:nil];
+            [bgView addSubview:medalImg];
+            
+            NSMutableAttributedString *vipImgAttri = [NSMutableAttributedString attachmentStringWithContent:bgView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(theBaseViewHeight, theBaseViewHeight) alignToFont:MOTextLabelFont alignment:YYTextVerticalAlignmentCenter];
+            [vipImgAttri appendAttributedString:[[NSAttributedString alloc] initWithString:@" "]];
+            [contentStr insertAttributedString:[vipImgAttri copy] atIndex:0];
+        }
+        else{
+            //旧版 VIP 静态图
+            UIImage *vipImg = [MOTextTools getVipIconWith:vipType];
+            NSTextAttachment *vipAttachment;
+            if(vipImg){
+                CGSize vipSize;
+                vipAttachment = [[NSTextAttachment alloc] init];
+                vipAttachment.image = vipImg;
+                //字体行高
+                UIFont *font = MOTextLabelFont;
+                CGFloat attachmentHeight = font.lineHeight;
+                CGFloat imgSizeHeight = GetParamNotZero(vipImg.size.height);
+                CGFloat attachmentWidth = attachmentHeight * vipImg.size.width/ imgSizeHeight;
+                vipAttachment.bounds = CGRectMake(0, (font.capHeight-font.lineHeight)/2, attachmentWidth, attachmentHeight);
+                vipSize = CGSizeMake(attachmentWidth, attachmentHeight);
+                
+                NSMutableAttributedString *vipImgAttri = [NSMutableAttributedString attachmentStringWithContent:vipImg contentMode:UIViewContentModeScaleAspectFit attachmentSize:vipSize alignToFont:MOTextLabelFont alignment:YYTextVerticalAlignmentCenter];
+                //生成NSAttributedString
+        //        NSMutableAttributedString *vipImgAttri = [[NSAttributedString attributedStringWithAttachment:vipAttachment] mutableCopy];
+                
+                [vipImgAttri appendAttributedString:[[NSAttributedString alloc] initWithString:@" "]];
+
+                [contentStr insertAttributedString:[vipImgAttri copy] atIndex:0];
+            }
+        }
+    }
+    return contentStr;
+}
+
 + (NSMutableAttributedString *)toAddLevelInfoWith:(NSMutableAttributedString *)contentStr And:(NSInteger)levelNum{
     
     NSArray *levelInfoArr = [MOSvgaSourceManage shareManager].allLevelSoureArr;
@@ -911,7 +966,7 @@
     }
 }
 
-+ (NSMutableAttributedString *)toAddSmallLevelInfoWith:(NSMutableAttributedString *)contentStr And:(NSInteger)levelNum{
++ (NSMutableAttributedString *)toAddSmallLevelInfoWith:(NSMutableAttributedString *)contentStr And:(NSInteger)levelNum AndHeight:(CGFloat)viewHeight{
     
     NSArray *levelInfoArr = [MOSvgaSourceManage shareManager].allLevelSoureArr;
     MOStoreInfo *medalInfo;
@@ -923,12 +978,15 @@
     }
     
     CGFloat levelHeight = 14.0;
+    if(viewHeight > 0){
+        levelHeight = viewHeight;
+    }
     
     if(medalInfo.res.length > 0){
         
         //这里调整的话, 请同时调整 MOBaseLevelView
         CGFloat levelWidth = MOLevelNormalWidth;
-        CGFloat levelLabelX = 14.0;
+        CGFloat levelLabelX = 13.0;
         CGFloat levelLabexWidth = levelWidth - levelLabelX;
         
         if(levelNum >= 100){
@@ -937,7 +995,7 @@
         }
         else if (levelNum < 10){
             levelWidth = MOLevelMixWidth;
-            levelLabelX = 13.0;
+            levelLabelX = 12.0;
             levelLabexWidth = levelWidth - levelLabelX;
         }
 
@@ -952,7 +1010,7 @@
         [bgView addSubview:levelImg];
         
         UILabel *levelLabel = [[UILabel alloc] initWithFrame:CGRectMake(levelLabelX, 0, levelLabexWidth, levelHeight)];
-        levelLabel.font = [MOTextTools poppinsExtraBoldFont:10.0];
+        levelLabel.font = [MOTextTools poppinsExtraBoldFont:8.0];
         levelLabel.textColor = [UIColor whiteColor];
         levelLabel.textAlignment = NSTextAlignmentCenter;
         levelLabel.text = [NSString stringWithFormat:@"%zd",levelNum];

+ 1 - 1
MiMoLive/Podfile.lock

@@ -288,7 +288,7 @@ SPEC CHECKSUMS:
   SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
   SnapKit: d612e99e678a2d3b95bf60b0705ed0a35c03484a
   SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
-  SVGAPlayer-iOS: a6c4a15c34b8a932ffc1102fbcd7c29edb820605
+  SVGAPlayer-iOS: 6134099e78f88927186aa74bf9be1f0302834724
   TIMCommon: 39343d50032dd1e022aef14faafdd59041cd4cfa
   TIMPush: e1d85ff0ee0c22cc3f51010ddd8de5316d60102c
   TUIChat: 47d612d109c68854b427dcfe92e109171559ae6a