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;

    }

  • 相关阅读:
    [No000068]document.body.clientHeight 和 document.documentElement.clientHeight 的区别
    [No000067]Js中获取当前页面的滚动条纵坐标位置scrollTop
    jquery 给a标签绑定click
    java 延时
    MySQL建表语句+添加注释
    ubuntu 搜狗输入法内存占用太多,卡顿不够处理办法
    org.apache.http.client.HttpClient使用方法
    json 文件打读取
    bootStrap @media 用法
    java web项目获取项目路径
  • 原文地址:https://www.cnblogs.com/Mr-------Li/p/5640263.html
Copyright © 2011-2022 走看看