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

// 我的名片

parent c805e4af
...@@ -13,7 +13,7 @@ class YHInterestTopicLayout: UICollectionViewFlowLayout { ...@@ -13,7 +13,7 @@ class YHInterestTopicLayout: UICollectionViewFlowLayout {
var dataSource:[String] = [] var dataSource:[String] = []
weak var layoutDelegate: UICollectionViewDelegateFlowLayout? = nil weak var layoutDelegate: UICollectionViewDelegateFlowLayout? = nil
var interItemSpacing: CGFloat = 12.0 // 相邻单元格之间的水平间距 var interItemSpacing: CGFloat = 12.0 // 相邻单元格之间的水平间距
let collectionViewWidth = KScreenWidth-16.0*4 var collectionViewWidth = KScreenWidth-16.0*4
override func prepare() { override func prepare() {
super.prepare() super.prepare()
self.minimumInteritemSpacing = 12 self.minimumInteritemSpacing = 12
......
...@@ -143,18 +143,15 @@ class YHMyInterestTopicCell: UITableViewCell { ...@@ -143,18 +143,15 @@ class YHMyInterestTopicCell: UITableViewCell {
layout.scrollDirection = .vertical layout.scrollDirection = .vertical
layout.dataSource = self.topicArr layout.dataSource = self.topicArr
layout.layoutDelegate = self layout.layoutDelegate = self
layout.collectionViewWidth = KScreenWidth-16.0*4
return layout return layout
}() }()
lazy var collectionView: UICollectionView = { lazy var collectionView: UICollectionView = {
// 创建集合视图布局
// 创建集合视图
let collectView = UICollectionView(frame:.zero, collectionViewLayout: self.layout) let collectView = UICollectionView(frame:.zero, collectionViewLayout: self.layout)
collectView.delegate = self collectView.delegate = self
collectView.dataSource = self collectView.dataSource = self
collectView.backgroundColor = .white collectView.backgroundColor = .white
// 注册自定义单元格
collectView.register(YHTopicItemCell.self, forCellWithReuseIdentifier: YHTopicItemCell.cellReuseIdentifier) collectView.register(YHTopicItemCell.self, forCellWithReuseIdentifier: YHTopicItemCell.cellReuseIdentifier)
return collectView return collectView
}() }()
......
...@@ -31,6 +31,7 @@ class YHMyNameCardAvatarInfoCell: UITableViewCell { ...@@ -31,6 +31,7 @@ class YHMyNameCardAvatarInfoCell: UITableViewCell {
let cityWidth = self.getWith(font: self.cityLabel.font, height: 20, string: city) let cityWidth = self.getWith(font: self.cityLabel.font, height: 20, string: city)
self.cityLabel.frame = CGRectMake(0, 0, cityWidth+8, 20) self.cityLabel.frame = CGRectMake(0, 0, cityWidth+8, 20)
self.zodiacLabel.text = self.userModel.zodiac self.zodiacLabel.text = self.userModel.zodiac
self.signImgV.isHidden = !self.userModel.isSigned
var name:ASAttributedString = .init(string:self.userModel.username, .font(UIFont.PFSC_B(ofSize: 18)), .foreground(UIColor.mainTextColor)) var name:ASAttributedString = .init(string:self.userModel.username, .font(UIFont.PFSC_B(ofSize: 18)), .foreground(UIColor.mainTextColor))
let cityTag: ASAttributedString = " \(.view(self.cityLabel, .original(.center)))" let cityTag: ASAttributedString = " \(.view(self.cityLabel, .original(.center)))"
...@@ -44,27 +45,38 @@ class YHMyNameCardAvatarInfoCell: UITableViewCell { ...@@ -44,27 +45,38 @@ class YHMyNameCardAvatarInfoCell: UITableViewCell {
} }
self.nameTextView.attributed.text = name self.nameTextView.attributed.text = name
var text1 = ""
if !self.userModel.position.isEmpty { if !self.userModel.position.isEmpty {
self.professionalLabel.text = self.userModel.position text1 = self.userModel.position
} else { } else {
self.professionalLabel.text = "" if self.userModel.isCurrentUser { // 当前用户默认文案
if self.userModel.isCurrentUser {
self.professionalLabel.textColor = UIColor.mainTextColor30 self.professionalLabel.textColor = UIColor.mainTextColor30
self.professionalLabel.text = "填写职位 | 填写所属行业" text1 = "填写职位 | 填写所属行业"
} }
} }
self.professionalLabel.text = text1
var text2 = ""
if !self.userModel.signature.isEmpty { if !self.userModel.signature.isEmpty {
self.detailLabel.text = self.userModel.signature text2 = self.userModel.signature
} else { } else {
self.detailLabel.text = "" if self.userModel.isCurrentUser { // 当前用户默认文案
if self.userModel.isCurrentUser {
self.detailLabel.textColor = UIColor.mainTextColor30 self.detailLabel.textColor = UIColor.mainTextColor30
self.detailLabel.text = "填写个性签名,展现真我风采,彰显独特身份" text2 = "填写个性签名,展现真我风采,彰显独特身份"
} }
} }
self.detailLabel.text = text2
self.signImgV.isHidden = !self.userModel.isSigned var top2Margin = 8.0
if text2.isEmpty {
top2Margin = 0.0
} else {
top2Margin = text1.isEmpty ? 0.0 : 8.0
}
self.detailLabel.snp.updateConstraints { make in
make.top.equalTo(self.professionalLabel.snp.bottom).offset(top2Margin)
}
self.setNeedsLayout()
self.layoutIfNeeded()
} }
} }
...@@ -227,7 +239,6 @@ class YHMyNameCardAvatarInfoCell: UITableViewCell { ...@@ -227,7 +239,6 @@ class YHMyNameCardAvatarInfoCell: UITableViewCell {
self.professionalLabel.snp.makeConstraints { make in self.professionalLabel.snp.makeConstraints { make in
make.left.equalTo(16) make.left.equalTo(16)
make.right.equalTo(-16) make.right.equalTo(-16)
// make.height.equalTo(20)
make.top.equalTo(self.nameTextView.snp.bottom).offset(0) make.top.equalTo(self.nameTextView.snp.bottom).offset(0)
} }
...@@ -235,7 +246,6 @@ class YHMyNameCardAvatarInfoCell: UITableViewCell { ...@@ -235,7 +246,6 @@ class YHMyNameCardAvatarInfoCell: UITableViewCell {
make.left.equalTo(16) make.left.equalTo(16)
make.right.equalTo(-16) make.right.equalTo(-16)
make.top.equalTo(self.professionalLabel.snp.bottom).offset(8) make.top.equalTo(self.professionalLabel.snp.bottom).offset(8)
// make.height.equalTo(18)
make.bottom.equalTo(-16) make.bottom.equalTo(-16)
} }
......
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