富文本

_labelOfDelegate.attributedText = [self attributedText];

#pragma mark - 富文本
- (NSAttributedString *)attributedText{

    NSString *strOfDelegate = @"我同意<<用户服务协议>>";
    NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:strOfDelegate];
    [attributedStr addAttribute:NSFontAttributeName
                      value:[UIFont systemFontOfSize:13.f]
                      range:NSMakeRange(0, 13)];

    [attributedStr addAttribute:NSForegroundColorAttributeName
                      value:[UIColor blackColor]
                      range:NSMakeRange(0, 3)];

    [attributedStr addAttribute:NSForegroundColorAttributeName
                      value:[UIColor colorWithRed:1.f green:0.84 blue:0.33 alpha:1.f]
                      range:NSMakeRange(3, 10)];
    return attributedStr;
}

你可能感兴趣的:(富文本)