zoukankan      html  css  js  c++  java
  • TTTAttributedLabel颜色设置

        NSString *text = @"Lorem ipsum dolor sit amet";
        [self.testAttributedLabel setText:text afterInheritingLabelAttributesAndConfiguringWithBlock:^ NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
            NSRange boldRange = [[mutableAttributedString string] rangeOfString:@"ipsum dolor" options:NSCaseInsensitiveSearch];
            NSRange strikeRange = [[mutableAttributedString string] rangeOfString:@"sit amet" options:NSCaseInsensitiveSearch];
            
            // Core Text APIs use C functions without a direct bridge to UIFont. See Apple's "Core Text Programming Guide" to learn how to configure string attributes.
            UIFont *boldSystemFont = [UIFont boldSystemFontOfSize:14];
            CTFontRef font = CTFontCreateWithName((__bridge CFStringRef)boldSystemFont.fontName, boldSystemFont.pointSize, NULL);
            if (font) {
                [mutableAttributedString addAttribute:(NSString *)kCTFontAttributeName value:(__bridge id)font range:boldRange];
                [mutableAttributedString addAttribute:kTTTStrikeOutAttributeName value:@YES range:strikeRange];
                CFRelease(font);
            }
            //TTTAttributedLabel颜色设置
            [mutableAttributedString addAttribute:(NSString*)kCTForegroundColorAttributeName value:(id)[[UIColor blueColor] CGColor] range:boldRange];
    //        [mutableAttributedString addAttribute:(NSString*)kCTForegroundColorAttributeName value:[UIColor blueColor] range:boldRange];
            
            return mutableAttributedString;
        }];
    

      

  • 相关阅读:
    springboot maven
    基于spring http服务远程调用
    java注解
    mongdob-高可用集群
    Mongodb学习笔记--分片集群
    Mongodb学习笔记--springboot中使用mongodb
    Mongodb学习笔记--用户和权限
    Mongodb学习笔记--使用java连接操作mongodb
    mongodb学习笔记--集群配置(二)-副本集配置
    mongodb学习笔记--集群配置(一)
  • 原文地址:https://www.cnblogs.com/Clin/p/4885978.html
Copyright © 2011-2022 走看看