Explorar el Código

标题显示不全问题

jsonwang hace 3 años
padre
commit
0e83d4e143
Se han modificado 1 ficheros con 9 adiciones y 6 borrados
  1. 9 6
      MusicVideoPlus/Classes/Modules/Home/Views/MVBannerCell.swift

+ 9 - 6
MusicVideoPlus/Classes/Modules/Home/Views/MVBannerCell.swift

@@ -128,8 +128,9 @@ class MVBannerCell: UICollectionViewCell {
 
     var videoData: PQVideoListModel? {
         didSet {
-            addData()
             addLayout()
+            addData()
+      
         }
     }
 
@@ -159,16 +160,18 @@ class MVBannerCell: UICollectionViewCell {
     func addData() {
         typeLab.text = "\(videoData?.categoryName ?? "")"
         BFLog(message: "videoDatavideoData \(String(describing: videoData?.title))")
+
+     
+       let textSize =  sizeWithText(text: videoData?.title ?? "", font: UIFont.systemFont(ofSize: 16, weight: .bold), size: CGSize.init(width:    adapterWidth(width: 300), height: CGFloat.greatestFiniteMagnitude))
         
-        let boundingRect : CGRect = (videoData?.title?.boundingRect(with: CGSize(width: 200, height: 0), options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16, weight: .bold)], context: nil)) ?? CGRect.init()
-        
+        BFLog(message: "XXXXXXX videoData?.title is \(String(describing: videoData?.title)) height \(textSize.height)  width is \(reCreateBtn.frame.maxX - 12)")
         titleLabel.snp.remakeConstraints { make in
-            make.right.equalTo(reCreateBtn.snp_right)
-            make.height.equalTo(boundingRect.height)
+            make.width.equalTo(  adapterWidth(width: 300))
+            make.height.equalTo(textSize.height + 2)
             make.left.equalToSuperview().offset(12)
             make.bottom.equalTo(musicContenView.snp_top).offset(-cDefaultMargin)
         }
-        BFLog(message: "videoData?.title is \(String(describing: videoData?.title))")
+        BFLog(message: "videoData?.title is \(String(describing: videoData?.title)) height \(textSize.height)")
         titleLabel.text = videoData?.title ?? ""