美文网首页
UIbutton 换行且不同字体大小颜色设置

UIbutton 换行且不同字体大小颜色设置

作者: wayne_YU | 来源:发表于2019-04-26 10:42 被阅读0次
    • (NSAttributedString *)getStrWithSring:(NSString *)leftStr rightStr:(NSString *)rightStr leftColor:(UIColor *)leftColor rightColor:(UIColor *)rightColor {
      NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@\n",leftStr]];
      [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"PingFangSC-Medium" size:18.0] range:NSMakeRange(0, str.length)];
      [str addAttribute:NSForegroundColorAttributeName value:leftColor range:NSMakeRange(0, str.length)];

      NSMutableAttributedString *str1 = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",rightStr]];
      [str1 addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"PingFangSC-Light" size:12.0] range:NSMakeRange(0, str1.length)];
      [str1 addAttribute:NSForegroundColorAttributeName value:rightColor range:NSMakeRange(0, str1.length)];

      [str appendAttributedString:str1];
      return str;
      }

    相关文章

      网友评论

          本文标题:UIbutton 换行且不同字体大小颜色设置

          本文链接:https://www.haomeiwen.com/subject/kjqfnqtx.html