iOS FlexLayout忽略垂直约束从容器中消失

时间:2019-06-20 10:10:44

标签: ios swift flexbox ios-flexbox

在tableview中使用FlexLayout为代码表视图单元格添加了垂直约束到flex容器

tagsView.willRemoveSubview(rootFlexContainer)
    tagsView.addSubview(rootFlexContainer)

     rootFlexContainer.flex.direction(.rowReverse).wrap(.wrap).alignSelf(.stretch).justifyContent(.start).paddingRight(5).define { (flex) in
        for i in 0..<(array.count > 3 ? 3 : array.count) {
            let nameLabel = TagLabel()
            //nameLabel.lineBreakMode = .byCharWrapping
            nameLabel.font = FontStyle.ProximaNovaRegular(size: 12)
            nameLabel.layer.borderColor = UIColor.hexStringToUIColor(hex: TravelXStrings.grayBorderColor).cgColor
            nameLabel.layer.cornerRadius = 5
            nameLabel.layer.borderWidth = 1.0
            nameLabel.textColor = .black
            nameLabel.text = " "+array[i]+" "
            //nameLabel.sizeToFit()
            flex.addItem(nameLabel).margin(2)
        }
        tagsView.flex.layout(mode: .fitContainer)
    }

override func layoutSubviews() {
    super.layoutSubviews()
    layout()
}

fileprivate func layout() {
    tagsView.flex.layout(mode: .fitContainer)
    //tagsView.flex.layout(mode: .adjustWidth)
}

这是屏幕截图

enter image description here

0 个答案:

没有答案