zoukankan      html  css  js  c++  java
  • 富文本(NSMutableAttributedString)

    干货:

    - (void)viewDidLoad {

        [super viewDidLoad];

        

        NSString * tempStr = @"貌似这个叫富文本";

        NSMutableAttributedString * attStr = [self stringTurnToAttributeStringWithString:tempStr

                                                                                    Font:25

                                                                               TextColor:[UIColor redColor]

                                                                                   Range:NSMakeRange(5, 3)];

        UILabel * label = [[UILabel alloc] initWithFrame:self.view.bounds];

        label.textAlignment = NSTextAlignmentCenter;

        label.attributedText = attStr;

        [self.view addSubview:label];

    }

    - (NSMutableAttributedString *)stringTurnToAttributeStringWithString:(NSString *)string

                                                                    Font:(CGFloat)fontSize

                                                               TextColor:(UIColor *)textColor

                                                                   Range:(NSRange)range{

        NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:string];

        [attStr addAttributes:@{NSForegroundColorAttributeName:textColor,

                                NSFontAttributeName:[UIFont systemFontOfSize:fontSize]}

                        range:range];

        return attStr;

    }

  • 相关阅读:
    tomcat启动与关闭脚本
    SqlAlchemy ORM
    python之socket
    python异常处理
    python常用模块
    PYTHON之文件操作
    Linux系统Load average负载详细解释
    tomcat报错:This is very likely to create a memory leak问题解决
    springcloud第一步:创建eureka注册服务
    SpringCloud微服务高级
  • 原文地址:https://www.cnblogs.com/Mr-------Li/p/5640263.html
Copyright © 2011-2022 走看看