【问题标题】:topLayoutGuide equivalent in UIPresentationController?UIPresentationController 中的 topLayoutGuide 等效项?
【发布时间】:2017-10-24 14:35:39
【问题描述】:

我有一个用于呈现视图控制器的自定义转换,我使用UIPresentationController 子类来执行呈现。

在演示控制器中,我向其containerView(镀铬)添加了几个子视图。我想用topLayoutGuide 之类的东西来限制其中一个,以说明任何顶部栏(如状态栏)的高度。

但是,UIPresentationController 不是 UIViewController 子类,因此它没有 topLayoutGuide 属性。我尝试使用presentingViewControllerpresentedViewControllertopLayoutGuide 约束视图,但应用程序崩溃了,因为它们不是同一视图层次结构的一部分。

那么有没有办法将子视图放置在演示控制器的 containerView 的顶部,同时仍然考虑任何顶部栏的高度?

【问题讨论】:

    标签: ios autolayout statusbar uipresentationcontroller uilayoutguide


    【解决方案1】:

    通过反复试验,我发现要使topLayoutGuide 工作,添加的视图控制器视图高度不大于屏幕尺寸高度非常重要。在UIViewControllerAnimatedTransitioningfunc animateTransition(using transitionContext: UIViewControllerContextTransitioning) 设置:

    toVC.view.frame = transitionContext.finalFrame(for: toVC)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-16
      • 2018-06-25
      • 2015-07-09
      • 2014-07-04
      • 2010-09-20
      • 2021-06-21
      • 2012-12-10
      • 2022-01-17
      相关资源
      最近更新 更多