TTT attributed Label Multi- colored Font help

前端 未结 2 377
青春惊慌失措
青春惊慌失措 2021-01-15 03:04
-(UITableViewCell*) makeLikeCell
 {
    // Load the top-level objects from the custom cell XIB.
NSArray *topLevelObjects = [[NSBundle mainBundle]      loadNibNamed:@         


        
2条回答
  •  醉酒成梦
    2021-01-15 03:38

    Use like this

    [likeLabel setText:likeText afterInheritingLabelAttributesAndConfiguringWithBlock: ^(NSMutableAttributedString *mutableAttributedString) {
        NSRange colorRange = [likeText rangeOfString: @"like this photo." options: NSCaseInsensitiveSearch];
        if (colorRange.location != NSNotFound) {
            [mutableAttributedString addAttribute:(NSString *) kCTForegroundColorAttributeName value:(id)[[UIColor grayColor] CGColor] range:colorRange];
        }
        return mutableAttributedString; 
    }];
    

提交回复
热议问题