zoukankan      html  css  js  c++  java
  • NSMutableAttributedString 富文本的使用

    //富文本的使用
        UILabel *testLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 100, 320, 30)];
        
        testLabel.backgroundColor = [UIColor lightGrayColor];
        
        testLabel.textAlignment = NSTextAlignmentCenter;
        
        NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"今天天气不错呀"];
        
        [AttributedStr addAttribute:NSFontAttributeName
         
                              value:[UIFont systemFontOfSize:25.0]
         
                              range:NSMakeRange(2, 2)];
        
        [AttributedStr addAttribute:NSForegroundColorAttributeName
         
                              value:[UIColor redColor]
         
                              range:NSMakeRange(2, 2)];
        
        testLabel.attributedText = AttributedStr;
        
        [self.view addSubview:testLabel];
  • 相关阅读:
    hrbust 1558 小背包(简单01背包)水坑
    hrbust 1174泉水(DFS深度优先搜索)
    HDU 1115
    HDU 4273
    HDU 2912
    POJ 3528
    HDU 1912
    HDU 4741
    HDU 4617
    POJ 1755
  • 原文地址:https://www.cnblogs.com/weiboyuan/p/5102875.html
Copyright © 2011-2022 走看看