我有一个字符串“专家销售经理”作为单元格标题,我只想突出显示 iphone 单元格标题中的“销售”。
请建议我这样做的方法。
3 回答
            0        
        
		
您可以NSMutableAttributedString用于 ios 6 或更高版本。
   NSMutableAttributedString * string = [[NSMutableAttributedString alloc] initWithString:@"OneTwoThreeFour"];
    [string addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Helvetica-Bold" size:20] range:NSMakeRange(3,5)];
并将您的属性文本设置为您的元素..
label.attributedText = string;
于 2013-05-14T06:42:56.690   回答
    
    
            0        
        
		
从iOS 6开始,UIKit 支持绘制属性字符串
来自UILabel:
@property(nonatomic, copy) NSAttributedString *attributedText;
你只需要建立你的NSAttributedString. 基本上有两种方式:
- 附加具有相同属性的文本块 - 为每个部分创建一个 - NSAttributedString实例并将它们附加到一个实例- NSMutableAttributedString
- 从纯字符串创建属性文本,然后为给定范围添加属性 - 找到您的数字(或其他)的范围并在其上应用不同的突出显示属性。 
于 2013-05-14T06:44:01.697   回答
    
    
            0        
        
		
您可以使用NSMutableAttributedString
NSString *infoString=@"This is an example of Attributed String";
NSMutableAttributedString *attString=[[NSMutableAttributedString alloc] initWithString:infoString];
NSInteger _stringLength=[infoString length];
UIColor *_black=[UIColor blackColor];
UIFont *font=[UIFont fontWithName:@"Helvetica-Bold" size:30.0f];
[attString addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, _stringLength)];
[attString addAttribute:NSForegroundColorAttributeName value:_black range:NSMakeRange(0, _stringLength)];
于 2013-05-14T06:44:02.727   回答