iPhone 中类之间转换的卷页效果
我正在使用页面卷曲效果。单击按钮后,我能够转换页面(即在 UIView 之间)。以下代码描述了
UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.5];
if ([sender tag] == 1) {
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:placeholder cache:YES];
}
else {
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:placeholder cache:YES];
}
if (view1OnTop) {
[view1 removeFromSuperview];
[placeholder addSubview:view2];
}
else {
[view2 removeFromSuperview];
[placeholder addSubview:view1];
}
[UIView commitAnimations];
view1OnTop = !view1OnTop;
与此相同的内容,我能够在 UIView 之间卷曲,但我的问题是,我会吗能够在两个或多个类之间应用这种转换??? 提前致谢
i am working with page curling effect .on click of a button i was able to transit the page(i.e between the UIViews).the following code depicts the same
UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.5];
if ([sender tag] == 1) {
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:placeholder cache:YES];
}
else {
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:placeholder cache:YES];
}
if (view1OnTop) {
[view1 removeFromSuperview];
[placeholder addSubview:view2];
}
else {
[view2 removeFromSuperview];
[placeholder addSubview:view1];
}
[UIView commitAnimations];
view1OnTop = !view1OnTop;
with this i was able to curl between UIViews ,but my question is , will i be able to apply this kind of transition between two or more classes???
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
并非所有东西都可以动画化。只有 UIKit 的一部分是。因此,如果您想问
NSObject
的任何子类是否可以动画,那么它们不能。如果您想问UIView
的子类是否可以动画,那么答案是肯定的。它们也可以是不同的子类。虽然这是可能的,但这并不意味着它会给我们正确的结果。他们最终可能看起来很奇怪。你可能不想这样做。图层也可以设置动画。
然而,这一切都取决于你所说的类的含义。
动画到新的视图控制器
假设您想改变在视图控制器之间切换的方式,可以使用
UIView< 的
transitionWithView:duration:..
类方法/代码>。例如,这将在推送新视图控制器时使用卷曲过渡。
对于 4.0 之前的 iOS 版本
由于它们不支持基于块的动画 API,因此您必须这样做,
Not everything is animatable. Only parts of UIKit are. So if you mean to ask if any subclass of
NSObject
can be animated then no they can't. If you mean to ask if whether subclasses ofUIView
can be animated then the answer would be yes. They can be different subclasses too. While this is possible, it doesn't mean it will give us the right results. They might end up looking pretty weird. You might not want to do that.Layers are animatable too.
However it all depends on what you mean by classes.
Animating to a new view controller
Say you want to alter the way you shift between view controllers, you can use
transitionWithView:duration:..
class method ofUIView
. An example,This will use the curl up transition when pushing the new view controller.
For iOS versions older than 4.0
Since they don't support block based animation APIs, you will have to do this,