将UIPercentDrivenInteractiveTransition的作用限制为最上面的视图 [英] Limit effect of UIPercentDrivenInteractiveTransition to topmost view

查看:61
本文介绍了将UIPercentDrivenInteractiveTransition的作用限制为最上面的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以将 UIPercentDrivenInteractiveTransition 的作用仅限于视图层次结构中最顶层的视图?

Is there a way to limit the effect of UIPercentDrivenInteractiveTransition to only the topmost view in a view hierarchy?

具体来说:如 此处交互式过渡将容器视图层的 speed 设置为0,然后操纵 timeOffset 进行过渡。

Specifically: as explained here and here the interactive transition sets the container view layer's speed to 0 and then manipulates the timeOffset to scrub through the transition.

例如,如果我在包含该视图的视图中有一个活动指示器,则交互式过渡也会在活动指示器的旋转动画中进行擦洗。它停止旋转,并且似乎在交互式过渡中前后滚动。

If for example I have an activity indicator in that containing view, the interactive transition also scrubs through the activity indicator's spin animation. It stops spinning and appears to "roll" forward and back with the interactive transition.

是否可以本地化设置 speed timeOffset 并阻止它们传播到任何或所有子视图?

Is there a way to localize the effect of setting speed and timeOffset and prevent them from propagating through to any or all subviews?

到目前为止,我可以想到两种可能的方法:

So far, I can think of two possible approaches:


  1. 创建屏障层:子类<​​code> CALayer 并覆盖 setTimeOffset:以防止或有选择地阻止更改

  1. Create a "barrier" layer: subclass CALayer and override setTimeOffset: to prevent or selectively prevent changes

子类或将 UIPercentDrivenInteractiveTransition 替换为可遍历子视图层次结构并有选择地仅击中某些视图的东西

Subclass or replace UIPercentDrivenInteractiveTransition with something that traverses the subview hierarchy and selectively hits only certain views

任何其他想法都会受到欢迎。

Any other ideas would be welcome.

推荐答案

这个问题的答案是否定的。根据 Apple CALayer 类采用 CAMediaTiming 允许层定义相对于其上层的时空。换句话说,在子层中指定的 timeOffset beginTime 的任何值都会与上面的层相加。正如文档所述,层树时间空间的概念提供了可扩展的时间轴,该时间轴从根层开始直至其子孙。

The answer to this question is no. According to Apple, the CALayer class adopts CAMediaTiming "allowing a layer to define a timespace relative to its superlayer". In other words, whatever values of timeOffset or beginTime are specified in a child layer are summed with the layers above. As the docs state, "This concept of a layer-tree timespace provides a scalable timeline that starts at the root layer, through its descendants."

UIPercentDrivenInteractiveTransition 通过擦拭 [transitionContext containerView] .layer timeOffset 而起作用。 ( transitionContext id< UIViewControllerContextTransitioning> )。

The UIPercentDrivenInteractiveTransition acts by scrubbing through the timeOffset of [transitionContext containerView].layer. (transitionContext is an id<UIViewControllerContextTransitioning>).

因此,它将应用时间偏移,然后该时间偏移将由子层链中的所有子层自动采用。

Therefore it is applying a time offset that is then automatically adopted by all child layers down the sublayer chain.

没有障碍或仅选择性地击中某些图层之类的东西,因为此时间的传播是由Core Animation内部处理的。

There is no such thing as a "barrier" or "selectively hitting only certain layers" because this time propagation is handled by Core Animation internally.

这篇关于将UIPercentDrivenInteractiveTransition的作用限制为最上面的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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