我试图在iPad上实现类似iBook商店的东西。 当您点击书籍封面时,它将翻转并以一种流畅的动作进行缩放,从书籍封面到空白背景 - 然后加载内容。
我尝试了不同的方法,首先翻转,然后缩放,我尝试将transitionFromView
包裹在animateWithDuration
块中,但我无法让它看起来正常。它会做一个然后做另一个,或者在最后一个案例做一个,然后'flickr'并且什么也不做。
[UIView transitionFromView:fromView
toView:toView
duration:0.8
options:UIViewAnimationOptionTransitionFlipFromRight
completion:^(BOOL finished) {
if (finished) {
[UIView animateWithDuration:0.4
animations:^{[fromView setFrame:originFrame];}
completion:^(BOOL finished){}];
}
}];
毫无疑问,块非常适合动画! 但是我怎样才能同时翻转和缩放呢?
提前致谢。
答案 0 :(得分:0)
通过对包含您在其间切换的视图的视图执行翻转,我能够使用非块动画生成此效果。
CGRect endFrame; //The frame of the view after animation
UIView *sview; //The superview containing the first view
UIView *view1; //The first view, to be removed from sview
UIView *view2; //The second view, to be added to sview
view2.frame = view1.frame;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.8];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:sview cache:YES];
[view1 removeFromSuperview];
[sview addSubview:view2];
sview.frame = endFrame;
[UIView commitAnimations];
为此,view2上的自动调整遮罩必须可以调整宽度和高度。