瀏覽代碼

no message

南鑫林 5 年之前
父節點
當前提交
bc22622876

+ 6 - 2
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/View/Cell/CardContent/PicVideo/CardContentPicVideoCollectionViewLayout.swift

@@ -65,10 +65,14 @@ class CardContentPicVideoCollectionViewLayout: UICollectionViewLayout {
 
                 }else{ //图片宽度大于图片高度
                     if (cardContentPicVideoModel?.width ?? 0) / (cardContentPicVideoModel?.height ?? 0) > 2 {
-                        return CGRect(x: 0, y: 0, width: (kScreenWidth-28), height: ((347 * (cardContentPicVideoModel?.height ?? 0)) / (cardContentPicVideoModel?.width ?? 0)) * kScaleWidth)
+                        let height = 347 * (cardContentPicVideoModel?.height ?? 0)
+                        let width = cardContentPicVideoModel?.width ?? 0
+                        return CGRect(x: 0, y: 0, width: (kScreenWidth-28), height: (height / width) * kScaleWidth)
 
                     }else {
-                        return CGRect(x: 0, y: 0, width: 232 * kScaleWidth, height: ((232 * (cardContentPicVideoModel?.height ?? 0)) / (cardContentPicVideoModel?.width ?? 0)) * kScaleWidth)
+                        let height = (232 * (cardContentPicVideoModel?.height ?? 0))
+                        let width = (cardContentPicVideoModel?.width ?? 0)
+                        return CGRect(x: 0, y: 0, width: 232 * kScaleWidth, height: (height / width) * kScaleWidth)
                     }
                 }
             case 2: