界面生成器中的UIView`learconContentGuide`?

时间:2015-07-22 17:03:32

标签: xcode interface-builder

iOS 9 readableContentGuide是一个UILayoutGuide(基本上,你可以限制的东西),所有UIViews都有。我们的想法是保持文字的子视图在iPad上的横向过宽。

在代码中配置它很容易(v1是子视图,v是其超级视图):

NSLayoutConstraint.activateConstraints([
    v1.topAnchor.constraintEqualToAnchor(v.readableContentGuide.topAnchor),
    v1.bottomAnchor.constraintEqualToAnchor(v.readableContentGuide.bottomAnchor),
    v1.rightAnchor.constraintEqualToAnchor(v.readableContentGuide.rightAnchor),
    v1.leftAnchor.constraintEqualToAnchor(v.readableContentGuide.leftAnchor)
])

现在。到现在为止还挺好。但是......在两个不同的WWDC视频中,非常明确地声明您可以将子视图固定到其界面生成器中的超级视图的readableContentGuide

但是他们没有解释你是如何那样做的。

所以我的问题是: 你是如何做到的?

1 个答案:

答案 0 :(得分:14)

像往常一样将子视图的边缘固定到超视图的边距。

现在,在 superview的尺寸检查器中,选中Follow Followable Width复选框:

enter image description here