我用UILabel设置了动画。我为UILabel添加了UITapGestureRecognizer。但是,我无法利用UILabel。
这是我的代码:
为UILabel添加手势:
UITapGestureRecognizer* gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapOnLabel:)];
gesture.numberOfTapsRequired = 1;
_lbAnimation.userInteractionEnabled = YES;
[_lbAnimation addGestureRecognizer:gesture];
动画UILabel
[UIView animateKeyframesWithDuration:6 delay:0 options:UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionCurveEaseOut animations:^{
_lbAnimation.frame=CGRectMake(0-(rect.size.width), _lbAnimation.frame.origin.y, rect.size.width, _lbAnimation.frame.size.height);
} completion:^(BOOL finished)
{
_viewAnimation.hidden = YES;
}];
handleTapOnLabel功能
- (void)handleTapOnLabel:(UITapGestureRecognizer *)tapGesture
{
CGPoint locationOfTouchInLabel = [tapGesture locationInView:tapGesture.view];
NSLog(@"_lbAnimation: %f : %f", locationOfTouchInLabel.x, locationOfTouchInLabel.y);
}
我不知道因为UILabel没有点击。
请帮帮我。