核心动画,意外的动画位置和hitTest值 [英] Core Animation, unexpected animated position and hitTest values

查看:104
本文介绍了核心动画,意外的动画位置和hitTest值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用:

When I use :

CALayer *hitLayer = 
[[self.view.window.layer presentationLayer] hitTest:pointOfTouch]; 


然后我探索图层,发现当前动画的所有属性都设置为最终状态。

I then explore the layer to discover that all the property that are animating at the moment are set to their final states.

我正在测试的图层是iOS 4.3中UIImageView的CALayer。
我还有一个关于UIImage视图的IBOutlet。所以我做了同样的测试:

The layer I'm testing on is the CALayer of an UIImageView in iOS 4.3. I also have an IBOutlet to that UIImage view. So I did the same test like this:

  CALayer *l = [self.topLeft.layer presentationLayer];
  NSLog(@"presentation layer frame for eloise is : %@", [self cgRectDescription:l.frame]);
  NSLog(@"and xPosition = %.2f, yPosition = %.2f & zPosition = %.2f", l.position.x, l.position.y, l.zPosition);


我仍​​然得到相同的结果。

我正在测试(void)touchesBegan:withEvent:当图像移动时。 >
这是我正在使用的动画

And I still get the same result.
I'm testing this in (void)touchesBegan:withEvent: while the image is moving.
Here is the animation I'm using

[UIImageView animateWithDuration:aDuration
                            delay:0
                          options:UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState
                       animations:^(void) {
                                  aIv.center = imageStartingPoint;
                                  aIv.layer.zPosition = 0;
                                  imageStartingPoint = CGPointZero;
                                  centerImage = nil;

这可能有点简单,但我不在乎,谢谢,

It's probably a little simple thing, but I'm out of idea, thanks,

推荐答案

我有一个解决方案。

我刚刚探索了一个想法,我意识到我没有检查CABasicAnimation(s)在表示层中表现正确的值...和。 ..他们是。

我必须在显式动画中做那些2,因为不支持隐含。

I just explored an idea, I realize that I didn't check if the value of the CABasicAnimation(s) where behaving correctly in the presentation layer... and... they were.
I had to do those 2 in explicit animation, because implicit was not supported.

所以我做了一些更基本的动画对于图像的中心和zPosition。
现在我在表示层中有信息。

So I made some more basic animation for the center of the image and the zPosition. And now I have the information in the presentation layer.

所以现在我可以得出结论,如果你需要获得一个有效的表示层,你绝对需要使用CAAnimation进行EXPLICIT动画。

So for now I can conclude that if you need to get a valid presentation layer you absolutely need to do EXPLICIT animation with a CAAnimation.

我有点难过,因为我喜欢UIView animateWithDuration:...

I'm kind of sad, because I was liking the UIView animateWithDuration:...

这篇关于核心动画,意外的动画位置和hitTest值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆