我想在接收 UILongPressGesture
时更改 View backgroundColor
,我该如何正确执行?使用下面的代码,所有内容都会永远卡住,即使我松开手指也不会解冻。
- (void)longPress:(UILongPressGestureRecognizer *)gesture {
while ([gestureRecognizer state] == UIGestureRecognizerStateChanged) {
[self.Row2View setBackgroundColor:[UIColor colorWithWhite:0.5 alpha:0.2]];
}
}
编辑 我需要的是:当 UILongPressGesture
改变颜色时,当手指抬起屏幕时变回颜色。
最佳答案
因为“while” block 永远不会中断!只需将“while” block 更改为“if”即可!
关于ios - 在 View 接收到手势时做某事,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29178120/