Dynamic layout UITableView's cell, header, footer

 

 

 

 

 

For added directly fixed on a display of a view on the line, similar to the above billing office card, add two controls with a bgView 

Requirements: The above view is UITableview the head, not the head partition, there is a display card module card, no card, no display

 

The best solution at this time, is the background to the card view into UIScrollView. Then add to it a highly constrained, because there are UIScrollView contentSize change constraints, the situation is the same disposition height 0 UIView but the child controls will not occur inside stays full

 

 

Code 

 

    /// 卡view的高度
    private var svHeightCon:NSLayoutConstraint?


    /// 卡view
    private func configCardBgSV() -> UIScrollView{
        let cardBgSV = JYUIModel.createScrollView(showVScrollIndicator: false, showHScrollIndicator: false, bounces: false)

        self.svHeightCon = cardBgSV.heightAnchor.constraint(equalToConstant: 56)
        self.svHeightCon?.isActive = true
    return cardBgSV
        
    }


数据更新的时候 改变约束高度

        /// 更新数据
    func updateData(topData:JYCustomerDetailTopStruct){
        if (topData.cardsNum.isEmpty) || (topData.cardsNum == "0"){
            self.svHeightCon?.constant = 0
        }else{
            self.svHeightCon?.constant = 56
        }
    }

 

 

Guess you like

Origin www.cnblogs.com/qingzZ/p/12015726.html