首页 > 其他 > 详细

uilabe下划线以及响应链接

时间:2014-12-06 15:26:55      阅读:235      评论:0      收藏:0      [点我收藏+]
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)

    {

//响应事件

.....

    }

}

uilabe下划线以及响应链接

原文:http://blog.csdn.net/gorgeous_xie/article/details/41775433

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!