How can I flip and enlarge a UIView it at the same time like iOS 7 iPad App Store?(如何像 iOS 7 iPad App Store 一样同时翻转和放大 UIView?)
问题描述
iPad iOS 7 App Store 有一个非常酷的动画,当您单击应用程序图标时(当图标较小时,从精选列表中,而不是搜索结果).这是它的图片:
The iPad iOS 7 App Store has a pretty cool animation for when you click on an app icon (from the featured list when the icon is smaller, not a search result). Here is a picture of it in action:
基本上,图标会同时翻转和扩大.
Basically, the icon flips and expands in size at the same time.
后面有渐变,内容视图更小.
There is a gradient behind it and the content view is smaller.
到目前为止,我有一个自定义的 VC 过渡设置,并且我的放大部分工作正常,但我无法让翻转.如何模仿 App Store 动画?
So far, I have a custom VC transition setup and I have the enlargement part working okay, but I can't get the flip to jive. How can I mimic the App store animation?
这是我目前的代码:
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
UIView *inView = [transitionContext containerView];
UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIView *fromView = [fromVC view];
UIView *toView = [toVC view];
toView.frame = [transitionContext finalFrameForViewController:toVC];
// Take a snapshot of the new view being presented
UIGraphicsBeginImageContextWithOptions(toView.bounds.size, NO, 0);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[fromView.layer renderInContext:ctx];
UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// Add the snapshot view and animate its appearance
UIImageView *intermediateView = [[UIImageView alloc] initWithImage:snapshot];
[inView addSubview:intermediateView];
[self calculateSourceRectInView:inView];
intermediateView.frame = self.sourceRect;
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
intermediateView.layer.transform = CATransform3DMakeRotation(-1.0 * -M_PI_2, 0.0, 1.0, 0.0);
intermediateView.frame = toView.frame;
} completion:^(BOOL finished) {
[intermediateView removeFromSuperview];
if ([transitionContext transitionWasCancelled]) {
[transitionContext completeTransition:NO];
} else {
[inView addSubview:toView];
[fromView removeFromSuperview];
[transitionContext completeTransition:YES];
// Now this is a pushed view, we allow interactive
// transitioning back to the parent view.
self.interactiveTransition = [EBInteractiveZoomTransition new];
[self.interactiveTransition wireToViewController:toVC];
}
}];
}
推荐答案
试试这个方法...
//set Intial Frame of view
[UIView transitionWithView: self.view
duration: 1.5f
options: UIViewAnimationOptionTransitionFlipFromRight
animations: ^(void)
{
}
completion: ^(BOOL isFinished)
{
// set the Final Frame of the View
}];
这篇关于如何像 iOS 7 iPad App Store 一样同时翻转和放大 UIView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何像 iOS 7 iPad App Store 一样同时翻转和放大 UIView?
基础教程推荐
- EditText 中的 setHintTextColor() 2022-01-01
- UINavigationBar 隐藏按钮文本 2022-01-01
- 在 iOS 7 下 CCMenu 错位 2022-01-01
- Firebase 云消息传递令牌未生成 2022-01-01
- 更改 UITableView 部分标题的颜色 2022-01-01
- 从 UIWebView 访问元数据 2022-01-01
- 在视图控制器的宽度上水平均匀分布 UIButton 的最简单方法? 2022-01-01
- UINavigationItem 的持久 rightBarButtonItem 属性 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android - 如何在runOnUiThread 中将数据传递给Runnable? 2022-01-01