如何给一个Label设置不同的文字属性

iOS中如何设置一段label如同上述效果 ?  代码如下:


    

    NSMutableAttributedString * string =[[NSMutableAttributedStringalloc]initWithString:@"你好,你今天吃饭了吗啊"];

    

    [string addAttribute:NSForegroundColorAttributeNamevalue:[UIColorredColor] range:NSMakeRange(0,2)];

    

    [string addAttribute:NSFontAttributeNamevalue:[UIFontsystemFontOfSize:40]range:NSMakeRange(3,2)];

    


    self.label.attributedText = string;


你可能感兴趣的:(如何给一个Label设置不同的文字属性)