Uiview Swift 3超过宽度时如何锚定底部

Uiview Swift 3超过宽度时如何锚定底部,uiview,swift3,autolayout,anchorpoint,Uiview,Swift3,Autolayout,Anchorpoint,我正在编写一个应用程序,我想知道当同一行的总宽度超过设备宽度时,如何将视图锚定到上一个视图的底部而不是右侧 基本上是这样的: View 1: width=150 anchor to superview's leftAnchor View 2: width=500 anchor to view1's rightAnchor View 3: width=1000 anchor to view1's bottomAnchor because total width in same row exceed

我正在编写一个应用程序,我想知道当同一行的总宽度超过设备宽度时,如何将视图锚定到上一个视图的底部而不是右侧

基本上是这样的:

View 1: width=150 anchor to superview's leftAnchor
View 2: width=500 anchor to view1's rightAnchor
View 3: width=1000 anchor to view1's bottomAnchor because total width in same row
exceeds device width

#device width=1200
感谢您的帮助。对不起,英语不好,不是以英语为母语的人


注:所有高度都相同,宽度都是动态的

主要的挑战是,在视图受到约束之前,我无法知道视图的宽度

所以我用了斯威夫特的估计

let size = CGSize(width: UIScreen.main.bounds.width, height: 50)
let attributeHeight = [NSFontAttributeName: UIFont.preferredFont(forTextStyle: .subheadline)]
let estimatedHeight = NSString(string: _title).boundingRect(with: size, options: .usesLineFragmentOrigin, attributes: attributeHeight, context: nil)
self._estimatedWidth = estimatedHeight.width + 32
在那之后,根据我的需要用for循环很容易地锚定它们