通过以下代码,我在手势识别器中添加了一个按钮:
通过这段代码
UILongPressGestureRecognizer *longPress=[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(addLongpressGesture:)];
[longPress setDelegate:self];
[BUTTON addGestureRecognizer:longPress];
这是我的addLongpressGesture方法:
- (void)addLongpressGesture:(UILongPressGestureRecognizer *)sender {
UIView *view = sender.view;
CGPoint point = [sender locationInView:view.superview];
if (sender.state == UIGestureRecognizerStateBegan){
// GESTURE STATE BEGAN
}
}
通过这段代码
sender.view
,我获得了附加的视图作为 UIView
但是我想要的是它附加的视图(UIButton),如何将 UIView 转换成 UIButton?