我如何翻转和在同一时间像iOS的7 iPad上的App Store放大一个UIView吗? [英] How can I flip and enlarge a UIView it at the same time like iOS 7 iPad App Store?

查看:250
本文介绍了我如何翻转和在同一时间像iOS的7 iPad上的App Store放大一个UIView吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

而iPad的iOS 7的App Store有当你点击应用程序图标(在功能列表时,该图标较小,不是搜索结果)一个pretty酷动画。这里是它在行动图片:

基本上,图标翻转并在同一时间在尺寸膨胀。

有它背后的渐变和内容的看法是小。

到目前为止,我有一个自定义VC过渡设置和我有膨大的部分工作还行,但我不能让翻转到摇摆。我怎样才能模仿App store的动画?

下面是code我到目前为止有:

   - (无效)animateTransition:(ID< UIViewControllerContextTransitioning>){transitionContext
UIView的* inView = [transitionContext containerView]
*的UIViewController = fromVC [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
*的UIViewController = toVC [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIView的* fromView = [fromVC视图]
UIView的* toView = [toVC视图]
toView.frame = [transitionContext finalFrameForViewController:toVC];//将新视图的快照是presented
UIGraphicsBeginImageContextWithOptions(toView.bounds.size,NO,0);
CGContextRef CTX = UIGraphicsGetCurrentContext();
[fromView.layer renderInContext:CTX];
* UIImage的快照= UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();//添加快照视图和动画外观
*的UIImageView = intermediateView [[UIImageView的页头] initWithImage:快照]
[inView addSubview:intermediateView];
[个体经营calculateSourceRectInView:inView];
intermediateView.frame = self.sourceRect;[UIView的animateWithDuration:[个体经营transitionDuration:transitionContext]动画:^ {
    intermediateView.layer.transform = CATransform3DMakeRotation(-1.0 * -M_PI_2,0.0,1.0,0.0);
    intermediateView.frame = toView.frame;
}完成:^(BOOL完){
    [intermediateView removeFromSuperview]    如果([transitionContext transitionWasCancelled]){
        [transitionContext completeTransition:NO];
    }其他{
        [inView addSubview:toView];
        [fromView removeFromSuperview]
        [transitionContext completeTransition:YES];        //现在,这是一个推来看,我们可以互动
        //转换回父视图。
        self.interactiveTransition = [EBInteractiveZoomTransition新]
        [self.interactiveTransition wireToViewController:toVC];
    }
}];
}


解决方案

试试这个方法...

  //设置Intial框架[UIView的transitionWithView:self.view
                  持续时间:1.5F
                   选项​​:UIViewAnimationOptionTransitionFlipFromRight
                动画:^(无效)
 {
 }
                完成:^(BOOL isFinished)
 {
      //设置视图的最后一帧
 }];

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.

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?

Here is the code I have so far:

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

解决方案

Try this way...

//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吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆