Commit dc76734c authored by Steven杜宇's avatar Steven杜宇

// 档案号显示

parent f884bc00
......@@ -36,6 +36,8 @@ class YHPrincipleProfileItemView: UIView {
lazy var titleLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_R(ofSize: 14)
label.numberOfLines = 0
label.lineBreakMode = .byCharWrapping
label.textColor = UIColor.mainTextColor(alpha: 0.7)
label.textAlignment = .left
return label
......@@ -202,6 +204,7 @@ class YHPrincipleProfileListCell: UITableViewCell {
var lastItemView: UIView = listTitleLabel
for (index, item) in items.enumerated() {
let itemView = YHPrincipleProfileItemView(frame: .zero)
let viewHeight = self.getHeight(text: item.name, font: itemView.titleLabel.font, width: KScreenWidth-118.0)
itemView.updateModel(item)
if model.type == .entry {
itemView.btnClick = {
......@@ -224,7 +227,7 @@ class YHPrincipleProfileListCell: UITableViewCell {
whiteView.addSubview(itemView)
itemView.snp.makeConstraints { make in
make.left.right.equalTo(0)
make.height.equalTo(YHPrincipleProfileItemView.viewH)
make.height.equalTo(viewHeight)
make.top.equalTo(lastItemView.snp.bottom).offset(16.0)
if index == items.count-1 {
make.bottom.equalTo(-16.0)
......@@ -289,4 +292,16 @@ class YHPrincipleProfileListCell: UITableViewCell {
make.bottom.equalTo(-32)
}
}
func getHeight(text:String, font:UIFont, width:CGFloat)-> CGFloat {
let size = CGSize.init(width:width , height: CGFloat(MAXFLOAT))
let dic = [NSAttributedString.Key.font: font]
let strSize = text.boundingRect(with: size, options: [.usesLineFragmentOrigin], attributes: dic, context:nil).size
var height = CGSizeMake(strSize.width, ceil(strSize.height)).height
if height < 20.0 {
var height = 20
}
return ceil(height)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment