效果图:
图片描述

代码示例:

    //在viewDidLoad中:   
    NSString * childNumber = [NSString stringWithFormat:@"%@", responseObject[@"rtn"][@"body"][@"serviceCount"]];
    NSString * item = [NSString stringWithFormat:@"目前正在管理服务%@名儿童", childNumber];
    NSMutableAttributedString * attString = [[NSMutableAttributedString alloc] initWithString:item];
    [attString addAttributes:@{NSForegroundColorAttributeName:kColorYellow} range:[item rangeOfString:childNumber]];
    itemLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 200, 20)];
    itemLabel.textColor = [UIColor whiteColor];
    itemLabel.attributedText = attString;
    self.navigationItem.titleView = itemLabel;

ShevaKuilin
388 声望32 粉丝

世间好物不坚牢,彩云易碎琉璃脆。