static func sizeOfContentLabel(label: UILabel,maxWidth: CGFloat) -> CGSize {
label.numberOfLines = 0
let maxSize: CGSize = CGSizeMake(maxWidth, CGFloat(MAXFLOAT))
let titleSize: CGSize = LabelTool.size(ofStr: label.text, andFont: label.font, andMaxSize: maxSize, andLineBreakMode: .byWordWrapping)
let updateSize : CGSize = CGSizeMake(maxWidth, titleSize.height+1)
return updateSize
}
let bottomLabel: UILabel = ZZCustomView.labelWithFont(fontSize: 15, text: bottomName, textColor: HexColor(0x333333))
let bottomSize: CGSize = ZZCustomView.sizeOfContentLabel(label: bottomLabel, maxWidth: ScreenW - 2 * 43)
self.addSubview(bottomLabel)
bottomLabel.textAlignment = .center
bottomLabel.snp.makeConstraints { make in
make.centerX.equalTo(topIconView)
make.top.equalTo(titleLabel.snp.bottom).offset(11)
make.size.equalTo(bottomSize)
}
网友评论