关于动画的 UIView 和 UIImageView 之间的关系... iPhone SDK
我的代码中有一些动画块,当我升级到 iPhone OS4 时,这些动画块导致了我的问题。我读到现在建议使用块动画,所以我想看看这是否能解决我的问题。在我使用以下类型的代码来制作动画之前...
[UIImageView beginAnimations:nil context:NULL];
[UIImageView setAnimationDuration:30.0];
[UIImageView setAnimationRepeatCount:1e100f];
[UIImageView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(stop)];
wheel.transform =CGAffineTransformMakeRotation(M_PI*-0.5);
[UIImageView commitAnimations];
我现在计划将其更改为使用这种类型的动画(取自 http://developer.apple.com/iphone/library/文档/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/doc/uid/TP40006816-CH3-SW111)
[UIView animateWithDuration:0.2
动画:^{ view.alpha = 0.0; }
完成:^(BOOL完成){ [查看 从超级视图中删除]; }]
我可以将上面的块动画与 UIImageView 而不是 UIView 一起使用吗?基本上我想我想知道有什么区别,如果我对 UIView 进行动画处理,我是否只是对 UIView 内的 UIImage 进行动画处理?那么这和 UIImageView 一样吗?!
抱歉我很困惑:-s
I have some animation blocks in my code which are causing my problems when I upgrade to iPhone OS4. I have read that it is now advised to use block-animations so I thought I would see if this solved my problems. Before I was using the following type of code to make an animation...
[UIImageView beginAnimations:nil context:NULL];
[UIImageView setAnimationDuration:30.0];
[UIImageView setAnimationRepeatCount:1e100f];
[UIImageView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(stop)];
wheel.transform =CGAffineTransformMakeRotation(M_PI*-0.5);
[UIImageView commitAnimations];
I am now planning to change this to use this type of animation (taken from http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/doc/uid/TP40006816-CH3-SW111)
[UIView animateWithDuration:0.2
animations:^{ view.alpha = 0.0; }
completion:^(BOOL finished){ [view
removeFromSuperview]; }]
My question is can I use the above block animation with UIImageView rather than UIView? Basically I guess I want to know what the difference is, if I animate a UIView would I just be animating a UIImage which is inside a UIView? Is this the same as a UIImageView then?!
Sorry I'm confused :-s
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UIImageView 是 UIView 的子类,因此 UIView 能做的一切也可以用 UIImageView 完成。
如果您对 UIView 进行动画处理,动画将影响其所有子视图。因此,如果 UIImageView 位于 UIView 之上,UIView 的动画将同时影响 UIView 和 UIImageView。
UIImageView is a subclass of UIView, so everything that you can do with UIView can be also done with UIImageView.
If you animate UIView, animation would affect all its subviews. So in case you have UIImageView on top of UIView, animation of UIView would affect both - UIView and UIImageView.