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];
}
相關文章
相關標籤/搜索