TTTAttributedLabel的使用

TTTAttributedLabelDelegate

@property (strong, nonatomic)TTTAttributedLabel *topTextLabel;

-(void)initWIthLabel{
    NSString * contentStr =QHLocalizedString(@"请上传三张不一样的AR宝箱识别图片,点击查看示例图片>>   咱们会在您上传的图片中选择识别度最高的一张进行藏宝", nil);
    NSString * linkStr =QHLocalizedString(@"点击查看示例图片>>", nil);
    NSMutableDictionary *linkAttribute = [NSMutableDictionary dictionaryWithCapacity:1];
    [linkAttribute setValue:(__bridge id)orangeColor.CGColor forKey:(NSString *)kCTForegroundColorAttributeName];
    _topTextLabel.linkAttributes = linkAttribute;
    _topTextLabel.delegate = self;
    _topTextLabel.font =[UIFont systemFontOfSize:13];
    _topTextLabel.numberOfLines =0;
    _topTextLabel.textColor =[UIColor lightGrayColor];
    [_topTextLabel setText:contentStr];
    NSRange linkRange = [contentStr rangeOfString:linkStr];
    [_topTextLabel addLinkToURL:[NSURL URLWithString:@""] withRange:linkRange];
}

#pragma mark -- TTTAttributedLabelDelegate
- (void) attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url {
    QHARUploadImageSamepleVC * VC =[[QHARUploadImageSamepleVC alloc]initWithNibName:@"QHARUploadImageSamepleVC" bundle:nil];
    [self.navigationController pushViewController:VC animated:YES];
}
相关文章
相关标签/搜索