iphone - 如何像iOS 7 iPad App Store一样同时翻转和放大一个UIView?

标签 iphone ios animation uinavigationcontroller ios7

iPad iOS 7 App Store 有一个非常酷的动画,当你点击一个应用程序图标时(来自特色列表,当图标较小时,不是搜索结果)。这是它的实际图片:

enter image description here

基本上,图标会同时翻转和扩大尺寸。

enter image description here

后面有渐变,content view变小了。

到目前为止,我有一个自定义的 VC 过渡设置,我的放大部分工作正常,但我无法让翻盖跳动。如何模仿应用商店动画?

这是我目前的代码:

- (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
 }];

关于iphone - 如何像iOS 7 iPad App Store一样同时翻转和放大一个UIView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19171918/

相关文章:

web-applications - 我可以 'frame' iPhone 应用程序中的网络应用程序吗

ios - 计算等距网格上矩形内包含的单元格

ios - DisplayActionSheet 仅在 xamarin ios 中引发异常

javascript - 如何将 svg "rgb()"属性的随机数值放入 "fill"中?

iOS Unity Asset Bundle 下载限制 - 粒子效果、动画和动画资源

javascript - Canvas 动画 - 基础知识

iphone - UITableView deleteRowsAtIndexPaths 不删除行

iphone - 创建一个将用户重定向到移动/HTML5 网站的 iPhone 应用程序

html - Div 从屏幕右侧溢出 - iphone

ios - React-Native-Webview:期望nodeHandle不为空