core animation - iOS animateWithDuration complete immediately for hiden/show or even opacity -
core animation - iOS animateWithDuration complete immediately for hiden/show or even opacity -
i want animate calayer show while, fade out, here code
[_msglayer removeallanimations]; [uiview animatewithduration:10 delay:0 options:0 animations:^ { _msglayer.hidden = false; nslog(@"showing"); } completion:^(bool finished) { nslog(@"showing done, finished=%d", finished); [uiview animatewithduration:10 delay:40 options:0 animations:^ { _msglayer.hidden = true; } completion:^(bool hidefinished) { nslog(@"hiding done, finished=%d", hidefinished); }]; }];
however, animation doesn't work expected, finish immediately
2014-10-26 10:11:28.249 foobar[91761:6827358] showing 2014-10-26 10:11:28.254 foobar[91761:6827358] showing done, finished=1 2014-10-26 10:11:28.255 foobar[91761:6827358] hiding done, finished=1
i see similar questions out there, people hidden
not animatable, document says it's animatable. , tried opacity
, same result, animation still finish immediately. why that? , how can solve that?
the _msglayer
own class inherits calayer , has own drawing method. , animation called networking event, server send message iphone, show message on screen.
the problem uiview animations meant animating views.
a high overview of what's happening when utilize uiview animations block gets executed, changes properties of view in turn changes backing layer (or changes layer properties directly). when (backing) layer's properties changes asks delegate (which view if layer backing view) provide action animation. view can check if alter happened within of animation block or not. if alter happened within of animation block, view homecoming animation right duration, timing curve, etc.
however, view's aren't attached layer, there no delegate ask. instead layer continues "action" (a more general term animation) , ends picking default action layer class. behavior outlined in the documentation -actionforkey:
method on calayer.
the default action (animations of paths beingness 1 exception) 0.25 sec long basic animation. animation seeing. layers animate changes default (it's view behavior disable this) see animation both changes within animation block , form outside animation block.
if want read more this:the first 3rd of my objc.io article here explain interaction between view , layer more closely. have a blog post here among other things explain difference between implicit , explicit animations.
the above explains why seeing behavior. "fix" either go higher abstraction , utilize view instead of layer or create animation objects , add together them layer (the work uikit doing @ view level).
ios core-animation
Comments
Post a Comment