Browse Source

UI 调整

jsonwang 3 years ago
parent
commit
4bb18afcac
1 changed files with 13 additions and 23 deletions
  1. 13 23
      BFFramework/Classes/Stuckpoint/View/PQEditPublicTitleView.swift

+ 13 - 23
BFFramework/Classes/Stuckpoint/View/PQEditPublicTitleView.swift

@@ -68,9 +68,7 @@ class PQEditPublicTitleView: UIView {
         flowLayout.minimumLineSpacing = 0
         flowLayout.minimumInteritemSpacing = 0
         flowLayout.scrollDirection = .vertical
-
-//        flowLayout.estimatedItemSize = UICollectionViewFlowLayout.automaticSize
-
+ 
         let collectionView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
 
         collectionView.showsVerticalScrollIndicator = false
@@ -173,7 +171,6 @@ class PQEditPublicTitleView: UIView {
 
     @objc func viewClick() {
         self.isHidden = true
-//        removeFromSuperview()
     }
 }
 
@@ -195,13 +192,11 @@ extension PQEditPublicTitleView: UICollectionViewDelegate, UICollectionViewDataS
 
     func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
         let title = titles[indexPath.row]
+ 
+        let textSize =  sizeWithText(text: title, font: UIFont.systemFont(ofSize: 17, weight: .regular), size: CGSize.init(width: 295, height: CGFloat.greatestFiniteMagnitude))
 
-        var titleHeight: CGFloat = 24 + 28
-        if title.count > 15 {
-            titleHeight = 48 + 28
-        }
-
-        return CGSize(width: cScreenWidth, height: titleHeight)
+        //28  是 cell label 上下边距总和
+        return CGSize(width: cScreenWidth, height: textSize.height + 28)
     }
 
      func scrollViewWillBeginDecelerating(_: UIScrollView) {
@@ -214,9 +209,10 @@ class PQEditPublicTitleViewContentCell: UICollectionViewCell {
         let titleLab = UILabel()
         titleLab.font = UIFont.systemFont(ofSize: 17, weight: .regular)
         titleLab.textColor = .black
+        titleLab.numberOfLines = 0
+        titleLab.lineBreakMode = .byCharWrapping
         titleLab.isUserInteractionEnabled = true
         titleLab.textAlignment = .left
-        titleLab.backgroundColor = .clear
         return titleLab
     }()
 
@@ -255,21 +251,15 @@ class PQEditPublicTitleViewContentCell: UICollectionViewCell {
 
     func addLayout() {
         
-        var titleHeight = 24 + 28
-        if (titleLab.text?.count ?? 0) > 15 {
-            titleHeight = 48 + 28
-            titleLab.numberOfLines = 2
-        }
-        
+        let textSize =  sizeWithText(text: titleStr ?? "", font: UIFont.systemFont(ofSize: 17, weight: .regular), size: CGSize.init(width: 295, height: CGFloat.greatestFiniteMagnitude))
   
-
-        titleLab.snp.makeConstraints { make in
-            make.height.equalTo(titleHeight)
+        titleLab.snp.remakeConstraints { make in
+            make.height.equalTo(textSize.height)
             make.right.equalToSuperview().offset(-64)
             make.left.equalToSuperview().offset(16)
             make.top.equalToSuperview().offset(14)
         }
-
+  
         lineView.snp.makeConstraints { make in
            
             make.right.equalToSuperview().offset(-64)
@@ -278,10 +268,10 @@ class PQEditPublicTitleViewContentCell: UICollectionViewCell {
             make.height.equalTo(1)
         }
 
-        iconView.snp.makeConstraints { make in
+        iconView.snp.remakeConstraints { make in
             make.width.height.equalTo(24)
             make.right.equalToSuperview().offset(-16)
-            make.top.equalTo(lineView.snp_top).offset(14)
+            make.top.equalTo(contentView.snp_top).offset(14)
         }
     }
 }