cocoa - CATransition 替换 subview :with…is animating all views

标签 cocoa animation core-animation nsview catransition

我怎样才能做到这一点,以便我的所有 View 的 subview 都不会在这里进行动画处理,而只有 currentPage 的representedView 和 newPage 的represented view ?

CATransition *transition = [CATransition animation];
    [transition setType:kCATransitionPush];
    [transition setSubtype:([self indexOfPage:currentPage] < [self indexOfPage:newPage]) ? kCATransitionFromRight : kCATransitionFromLeft];


    NSDictionary *ani = [NSDictionary dictionaryWithObject:transition 
                                                    forKey:@"subviews"];
    [self setAnimations:ani];
    [self.animator replaceSubview:currentPage.representedView with:newPage.representedView];

最佳答案

首先,当这正是您为其创建动画的属性时,您要求不对 subview 设置动画似乎很奇怪,因此我不太清楚您要做什么。

其次,动画的默认行为是为 View 及其所有 subview 设置动画。如果您只想为父 View 和特定 subview 设置动画,则不应将不想设置动画的 View 添加为 subview ,而应使用正确的 z 顺序使它们成为同级 View 。

关于cocoa - CATransition 替换 subview :with…is animating all views,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3274829/

相关文章:

macos - 在 IB 中的两个 nsbutton 之间设置响应者链

objective-c - KVC setNilValueForKey : recommends calling method and not using property accessor

iphone - iOS:从 AppDelegate 访问导航 View Controller

javascript - 使用 jQuery/HTML5 制作圆圈动画

iphone - 如何使用 AVAssetExportSession 在 AVMutableComposition 之上正确导出 CALayer

iphone - 如何为 CAShapeLayer 路径和 fillColor 设置动画

objective-c - 对象未从 NSOutlineView/ManagedObjectContext 中删除

ios - 扩展 UIViewPropertyAnimator?

javascript - 如何使用 jQuery 创建具有不同对象的圆形动画?

iPhone:通过从顶部向下拉图像来滑入和滑出 View