Kas*_*hif 1 autolayout uicollectionview swift uicollectionviewflowlayout
我在用
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: 400, height: 600)
}
Run Code Online (Sandbox Code Playgroud)
指定 myCollectionView的像元大小。它工作正常,但是一旦我(UILabel.width == ContentView.width)在单元格UILabel内部添加宽度约束ContentView,单元格的宽度就会缩小到 的固有宽度UILabel。
我正在使用UICollectionViewDelegateFlowLayout水平滚动。
如何强制坚持ContentView我指定的单元格大小并让子视图遵循自动布局约束?
| 归档时间: |
|
| 查看次数: |
834 次 |
| 最近记录: |