如何向 UIImageView 的子类添加自定义动画属性?
我有从 UIImageView 子类化的类。然后,该类的实例将作为子视图添加到我的应用程序的根类中。现在,我可以为其属性设置动画,例如 setFrame:
[UIView beginAnimations:nil context:nil];
...
[myImageView setFrame:someFrameCreatedInCode];
...
[UIView commitAnimations];
这将当前帧作为初始状态并插入 imageview 动画(它只是从左向右移动)。 这部分工作正常。
接下来我想做的是向我的类添加一个属性,例如整数类型。我希望这个属性能够指定图像编号(它的名称已格式化)并稍后制作基于帧的动画。这似乎是创建动画的好方法,因为我可以指定“曲线”来影响动画计时:
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
如何实现我自己的可以设置动画的属性?
提前致谢!
I have the class that I subclassed from UIImageView. The instance of this class is then added as a subview to the my application's root class. Now, I can animate it's properties, for example, setFrame:
[UIView beginAnimations:nil context:nil];
...
[myImageView setFrame:someFrameCreatedInCode];
...
[UIView commitAnimations];
This takes the current frame as the initial state and interpolates imageview animation (it simply moves from the left to the right). This part works fine.
What I would like to do next is I want to add a property to my class, say, of integer type. And I want this property to cpecify the image number (it's name is formatted) and make frame based animation later. It seems to be a nice way to create animation because I can specify the "curve" to affect the animation timing:
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
How to implement my own property which is possible to animate?
Thanks in advance!
Update: In case someone will need this I found these tutorials in the Internet: blog post, sample.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能希望将 UIView 动画与 UIImageView 动画图像一起使用。
如果您使用这样的代码:
我认为唯一的问题是同步两个动画......
You'd probably want to use the UIView animations together with the UIImageView animation images.
If you use a code like this:
I think the only problem would be synchronizing the two animations ...