一个带下划线的UILabel,当然下划线可有可无。
https://github.com/Easyzhan/customcustomLabel/tree/master/CustomLabelClick
写完之后恍然大明白。给label加个手势不得了。于是应运而生。
UILabel *labClicked = [[UILabel alloc] initWithFrame:CGRectMake(60, 0, 60, 60)];
labClicked.backgroundColor = [UIColor redColor];
labClicked.text = @"阿三";
labClicked.userInteractionEnabled = YES;
UITapGestureRecognizer *labelTapGestureRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(labelTouchUpInside:)];
[labClicked addGestureRecognizer:labelTapGestureRecognizer];
[self.view addSubview:labClicked];
华丽分割线------------------------
-(void) labelTouchUpInside:(UITapGestureRecognizer *)recognizer{
UILabel *label=(UILabel*)recognizer.view;
NSLog(@"%@被点击了",label.text);
}