IOS为问Label添加点击事件

self.labelText.userInteractionEnabled = YES;
    UITapGestureRecognizer* gesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handlerTap:)];
    gesture.numberOfTouchesRequired = 1;
    [self.labelText addGestureRecognizer:gesture];
-(void)handlerTap:(UITapGestureRecognizer*)gesture
{
    NSLog(@"点击");
}

你可能感兴趣的:(ios开发)