CATransition ReplaceSubView:with…正在对所有视图进行动画处理

发布于 2024-09-10 12:07:39 字数 643 浏览 10 评论 0原文

我怎样才能做到这一点,以便我的所有视图的子视图都不会在这里进行动画处理,而只有 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];

how can I make it so all of my view's subviews aren't animated here and only the currentPage's representedView and the newPage's represented view's?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执手闯天涯 2024-09-17 12:07:39

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

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

First, it seems odd that you are requesting to not animate subviews when this is the exact property you created your animation for so I'm not real clear on what you're trying to do.

Second, the default behavior for animation it to animate the view and all of its subviews. If you want to only animate the parent view and specific subviews, you should not add the views you don't want to animate as children of it, but rather make them siblings with the proper z order.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文