How's the iOS core animation works for setting a image with animation
I'm wondering how's the iOS core animation working, as the following code, it will performs well by setting the new image with animation.
I can understand how the animation works if I set the button's position in the animation block - the framework will calculate the each offset for each animation step, based on the button's original position and the target position, then update it's frame for each animation step. However this simple logic definitely can not apply for the following case. Experts please help me to understand, thanks!
[UIView transitionWithView:self.view
duration:0.35
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
[myButton setImage:[UIImage imageNamed:@"demo_button_view"] forState:UIControlStateNormal];
[myButton setImage:[UIImage imageNamed:@"demo_button_pressed_icon"] forState:UIControlStateHighlighted];
}
You don't use those transition settings like that. Those are used in methods like transitionFromView:toView:duration:options:completion:
As to how it works internally, it animates the alpha value of the 2 views, starting with the beginning view at alpha 1.0 and the new view at alpha at 0, and ending with the starting view at an alpha of 0 and the new view at an alpha of 1.
It looks like the sample app PrefsInCloud has an example of using the UIViewAnimationOptionTransitionCrossDissolve transition.
链接地址: http://www.djcxy.com/p/39494.html上一篇: 在Swift中将CAShapeLayer路径从旧值移动到新值
下一篇: iOS核心动画如何用于动画设置图像