1.
NSMutableAttributedString *content = [[NSMutableAttributedString
alloc]initWithString:[NSString
stringWithFormat:@"注册即视为同意xxx注册协议"]];
2.
NSRange contentRange = {0,[content
length]};
[content addAttribute:NSUnderlineStyleAttributeName
value:[NSNumber
numberWithInteger:NSUnderlineStyleSingle]
range:contentRange];
3.
label.attributedText = content;
响应链接:
1.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches
anyObject];
CGPoint points = [touch
locationInView:self.view];
//找到相应的label标签
UILabel *label = (UILabel *)[self.view
viewWithTag:kLinkLabel];
//判断当前触摸点的范围是否在标签位置所在范围内
if (points.x >= label.frame.origin.x && points.y
>= label.frame.origin.y && points.x <= label.frame.size.width
+ label.frame.origin.x && points.y <= label.frame.size.height
+label.frame.origin.y)
{
//响应事件
.....
}
}