:
Code:
#import "ViewController.h"
@interface Viewcontroller ()
@end
@implementation Viewcontroller
-(void) Viewdidload {
[Super Viewdidload];
UILabel *lab = [[UILabel alloc] Initwithframe:cgrectmake (10, 20, 300, 50)];
Lab.numberoflines = 0;
Lab.text = @ " The dim and hazy: Suddenly the return of the pizza can be a classic money to lose weight of the classics scattered points redemption can be comfortable places to take a holiday ah, we think the barber shop said is Curry Futing a happy to sprinkle into the bomb shelter hot and sour powder to understand the sprinkle fertilizer Danjiangkou ah, we look at the environment of Satan spread out of Caesar's coffee shop in the air, 。 ";
Lab.font = [Uifont systemfontofsize:10];
Nsrange range = [Lab.text rangeofstring:@ ":"];
[Self.view Addsubview:lab];
nsmutableattributedstring *att = [[Nsmutableattributedstring alloc] initWithString:lab.text];
[Att addattributes:@{nsforegroundcolorattributename:[uicolor redcolor]} range:nsmakerange (0, range.location+1)];
Lab.attributedtext = att;
UILabel *LAB1 = [[UILabel alloc] Initwithframe:cgrectmake (10, 80, 300, 20)];
Lab1.text = @ "Bounce is away from the reply stars Light chase:" Good silly You ";
Lab1.font = [Uifont systemfontofsize:10];
[Self.view ADDSUBVIEW:LAB1];
Nsrange Range1 = [Lab1.text rangeofstring:@ "reply"];
Nsrange range2 = [Lab1.text rangeofstring:@ ":"];
nsmutableattributedstring *att1 = [[Nsmutableattributedstring alloc] initWithString:lab1.text];
[Att1 addattributes:@{nsforegroundcolorattributename:[uicolor Redcolor]} range:nsmakerange (0, range1.location)];
[Att1 addattributes:@{nsforegroundcolorattributename:[uicolor Redcolor]} range:nsmakerange (range1.location+2, Range2.location-range1.location-1)];
NSLog (@ "%d%d", range1.location,range2.location);
Lab1.attributedtext = ATT1;
}
@end
iOS Rich Text instance