iPad iOS 7应用商店在您点击应用图标时(从特色列表中,当图标较小时,而不是搜索结果),有一个非常酷的动画效果。下面是它的图片:
基本上,图标会翻转并同时扩大。
背景有渐变,内容视图较小。
到目前为止,我已经设置了自定义VC转换,并且已经使放大部分正常工作,但我无法使翻转同步。如何模仿应用商店的动画?
这是我目前的代码:
基本上,图标会翻转并同时扩大。
背景有渐变,内容视图较小。
到目前为止,我已经设置了自定义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];
}
}];
}