[英]CALayer animating the Bounds
Is it possible to animate the bounds of the CALayer on iPhone? 是否可以在iPhone上为CALayer的边界设置动画? How to implement that?
如何实现呢? Thanks!
谢谢!
Yes, it is possible. 对的,这是可能的。
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0f];
[[self view] setBounds:CGRectMake(0.0f, 0.0f, 200.0f, 200.0f)];
[UIView commitAnimations];
This will animate a view controller's view from it's current bounds to a bounds of 200 x 200 over 1 second. 这将在1秒钟内将视图控制器的视图从当前边界动画化为200 x 200的边界。 It won't change the origin--just the size of the bounds rectangle.
它不会改变原点-只是边界矩形的大小。 This is implicit animation by the way.
顺便说一下,这是隐式动画。 If you want a more complicated animation, look at using CABasicAnimation and animating explicitly.
如果需要更复杂的动画,请查看使用CABasicAnimation并显式设置动画。
Are you trying to animate the visible part of an image inside a layer, were the layer itself maintains size and position? 您是否要为图层内图像的可见部分设置动画,图层本身是否保持大小和位置?
That's what CAScrollLayer
is made for. 这就是
CAScrollLayer
的用途。 Use a CAScrollLayer
in place of your current Layer and add image-rendering layerl as a subLayer to the CAScrollLayer
. 使用
CAScrollLayer
代替当前的Layer并将图像渲染layerl作为subLayer添加到CAScrollLayer
。 You can then use the transform
property of the sublayer to achieve that effect. 然后,您可以使用子层的
transform
属性来实现该效果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.