我使用arrangeSubView属性将标签作为子视图添加到UIstackview。
如果我将Stackview轴保持水平,会发生什么 我得到一个UILabels水平条带
label1 label2 label3 label4.....
如果我保持垂直,我会得到一个UILabels的垂直条带 如下所示
label1
label2
label3
and so on
但我想要实现的是这个
label1, label2(if it fits) otherwise take it below
label3, label4
label5 and so on
目前我的代码是这个
uiLabel1.numberOfLines = 1
uiLabel1.backgroundColor = THEMECOLOR
uiLabel1.font = UIFont.preferredFontForTextStyle(UIFontTextStyleCaption1)
uiLabel1.textColor = topicColor
uiLabel1.layer.cornerRadius = (CGFloat)(5.0)
uiLabel1.layer.masksToBounds = true
uiLabel1.sizeToFit()
uiLabel1.userInteractionEnabled = true
self.dynamicStackView.addArrangedSubview(uiLabel1)