Jus*_*ler 6 iphone animation uiview gesture completion-block
我有以下代码:
[UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction
animations:^{
imageView.bounds = endBounds;
}
completion:^(BOOL finished) {
[UIView animateWithDuration:2.0 delay:0.5 options:UIViewAnimationOptionAllowUserInteraction
animations:^{
imageView.bounds = startBounds;
}
completion:^(BOOL finished) {
[imageView removeFromSuperview];
}];
}];
Run Code Online (Sandbox Code Playgroud)
另外我有:
[imageView setUserInteractionEnabled:YES];
Run Code Online (Sandbox Code Playgroud)
以及一个轻击手势识别器设置,用于处理用户点击imageView.当第一个动画发生时,手势识别器会像我期望的那样触发.但是如果我尝试在完成块的链式动画中点击imageView,即使我已经设置了适当的选项也没有任何反应.
有人有什么想法?我用谷歌搜索,找不到答案.
jam*_*mur 27
使用新动画块时,如果要在动画期间启用用户交互,则必须在选项掩码中进行设置.例如:
[UIView animateWithDuration:1.0
delay:0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{ myView.alpha = 0.5; }
completion:NULL];Run Code Online (Sandbox Code Playgroud)
我提出了一个解决方案:
我将UIImageView包装在UIView(我的子类UIView)中,其边界/中心点与图像相同.然后我将手势识别器附加到包装器而不是图像.因为包装器的边界矩形/中心点在动画持续时间内永远不会改变,所以它始终可用作手势的目标.
这非常有效.
-j
| 归档时间: |
|
| 查看次数: |
10624 次 |
| 最近记录: |