English 中文(简体)
iPhone Flip Transition - Can I get notified at the half way point
原标题:

I have a single UIView for drawing any one of a set of items. That is, my one UIView subclass can be told to draw a square, circle, or triangle for example.

I d like to have a transition to flip that view so that the UIView draws a different shape at the half way point, so it looks like I m transitioning to a different view, but really I m just redrawing the single view at the half way point of the transition.

Is there a way to do this, without resorting to using two different UIViews and swapping them out in the animation block? It would be a bit clumsy for me to rejig what I have to use the swap mechanism.

Ideally all I need is some callback or notification that the animation is at the half way point, and then I can redraw the view with the new shape then.

Thanks for any help!

最佳回答

Even if you did know the midpoint of your flip animation, I don t believe redrawing the content of the view mid-animation would do anything. I think that the contents of the view s layer are cached at the beginning of the animation and don t change as the animation proceeds. Also, your view would end up inverted, left to right, at the end of the animation if you didn t have another view behind it.

If you wish to do this as a custom animation, you could break this into two halves using something like Mike Lee s Lemur Flip implementation that I describe in this answer. After the first half of the animation, you could redraw the view s content and complete the animation, ending up back where you started.

However, to me it seems more clumsy to not switch views in response to the transition. It certainly will take a lot more code to do.

问题回答

you can try to do smth like this. For example, your animationDuration property is set to 2.0f. so, the half way point is 1 second, so you can use

[self performSelector:@selector(yourCallbackMethod) withObject:nil afterDelay:1.0f];

The only way I know of that you could do this is to re-create the animation using Core Animation and then monitor the animation in the presentationLayer using a timer. There is no KVO available in Core Animation Layers so you have to monitor it explicitly.

In other words, it s probably not worth it. I suggest you think of a different way to solve your problem.





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签