TTT attributed Label Multi- colored Font help

前端 未结 2 353
青春惊慌失措
青春惊慌失措 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:29

    There is a way to set different / multiple fonts & other properties like color on Label using NSMutableAttributedStrin. Refer to my answer on Multiple Font & Color for string & Display the string on Label

    0 讨论(0)
  • 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; 
    }];
    
    0 讨论(0)
提交回复
热议问题