NSString * strDesc = @"请您认真阅读《注册条款》、《隐私策略》并同意后点击勾选,我们将尽全力保护您的个人信息安全。";
lblActicle.font = font;
lblActicle.textColor = color;
lblActicle.delegate = self;
lblActicle.lineSpacing = 4;
lblActicle.enabledTextCheckingTypes = NSTextCheckingTypeLink;
[lblActicle setText:strDesc afterInheritingLabelAttributesAndConfiguringWithBlock:^NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
return mutableAttributedString;
}];
//设置可点击文字的颜色和去除下划线
lblActicle.linkAttributes = @{(NSString *)kCTForegroundColorAttributeName:color_LinkURL,
(NSString *)kCTUnderlineStyleAttributeName:[NSNumber numberWithBool:NO]};
//设置点击时文字的颜色
lblActicle.activeLinkAttributes =@{(NSString *)kCTForegroundColorAttributeName:[color_LinkURL colorWithAlphaComponent:0.6]};
//设置点击文字
[lblActicle addLinkToURL:[NSURL URLWithString:RegisterUrl] withRange:[strDesc rangeOfString:@"《注册条款》"]];
[lblActicle addLinkToURL:[NSURL URLWithString:StatementUrl] withRange:[strDesc rangeOfString:@"《隐私策略》"]];
#pragma mark - TTTAttributedLabelDelegate
- (void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url{
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
}
TTTAttributedLabel 使用小记
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...