CATransition推,不褪色 [英] CATransition push without fade

查看:108
本文介绍了CATransition推,不褪色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Mac OS X创建了一个导航控制器类。

I'm making a navigation controller class for Mac OS X.

我要用 kCATransitionPush 动画。

像这篇文章一样:

核心动画教程 - 向导对话框与转换

CATransition 设置如下:

CATransition *transition = [CATransition animation];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[self.view setAnimations:@{ @"subviews" : transition }];






但是,当我替换视图时,正在自动添加的淡入淡出动画。


However, when I replace the views, there is a fade animation, which is being automatically added.

[NSAnimationContext beginGrouping];
{
    [[self.view animator] replaceSubview:_currentViewController.view with:newViewController.view];
}
[NSAnimationContext endGrouping];






如何做一个没有衰落的推动动画?


How can I do a push animation without the fading?

推荐答案

我发现获得平滑的Core Animation转换的最佳方式,无论视图是否支持CA

The best way I've found to get smooth Core Animation transitions that works regardless of whether the view supports CA or not is to do the following:


  1. 使用 NSView -cacheDisplayInRect创建一个要设置动画的视图的图像:toBitmapImageRep 或类似方法

  2. 将该图像放在NSImageView中

  3. 返回图像视图

  4. 将图片视图作为子视图添加到您要尝试转换的视图
  5. >
  6. 动画完成后移除图片视图

  1. Create an image of the view you are trying to animate, using NSView -cacheDisplayInRect:toBitmapImageRep or a similar method
  2. Put that image in an NSImageView
  3. Layer back the image view, which will draw fine without glitches when layer backed
  4. Add the image view as a subview over the view that you are trying to transition
  5. Animate the image view frame using NSView's animator proxy
  6. Remove the image view once the animation has completed

这篇关于CATransition推,不褪色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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