Tap Gesture on part of UILabel

前端 未结 5 1014
[愿得一人]
[愿得一人] 2020-12-10 18:56

I could successfully add tap gestures to a part of UITextView with the following code:

UITextPosition *pos = textView.endOfDocument;// textView ~ UITextView
         


        
5条回答
  •  Happy的楠姐
    2020-12-10 19:10

    This is basic code for how can add UITapGestureRecognizer to your control;

    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];        
    [MyLabelName addGestureRecognizer:singleTap];        
    [self.view addSubView:MyLabelName]
    

    This is method that call when you tapped your MyLabelName;

    -(void)handleSingleTap:(UILabel *)myLabel
    {
        // do your stuff;
    }
    

提交回复
热议问题