This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ExtensionFile.swift | |
| // TestSwift | |
| // | |
| // Created by Eddie on 2022/8/18. | |
| // | |
| import UIKit | |
| import SwiftUI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (CGFloat)collectionViewCellWidth:(UICollectionView *)collectionView itemCountPerRow:(NSInteger)count indexPath:(NSIndexPath *)indexPath { | |
| // 处理collectionView小数点bug,因为collectView是智能布局,当出现小数点时会随机分配宽度 | |
| NSInteger columnCount = count; | |
| NSInteger cellWidth = round(collectionView.width / columnCount); // 四舍五入 | |
| if (indexPath.row % columnCount == 0 ) { | |
| if (cellWidth * columnCount > collectionView.width) { | |
| return cellWidth - (cellWidth * columnCount - collectionView.width); | |
| } else { | |
| return collectionView.width - cellWidth * (columnCount - 1); |