我怎样才能做到这一点,以便我的所有 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/