-2

나는 여기에 그림과 같아야합니다 사용자 정의 레이아웃을 만들려면 : 내가 더 많거나 적은 동일하지 레이 Wenderlich (https://www.raywenderlich.com/107439/uicollectionview-custom-layout-tutorial-pinterest)에 의해 튜토리얼을 발견하지만가 복잡이었다쉬운 UICollectionView 사용자 레이아웃

Custom Layout 그래서 나는 이것을 나의 필요에 옮길 수 없었다.

난 그냥 쉽게 레이아웃이 필요하고, 또한 내 셀의 크기를 알고, 나는 그들을 계산할 필요가 없습니다. 아무도 도와주세요.

+0

이 레이아웃은 플로우 레이아웃 너무 위임 방법을 사용하다 - (CGSize) collectionView : (UICollectionView *) 컬렉션보기 레이아웃 : (UICollectionViewLayout *) collectionViewLayout sizeForItemAtIndexPath : (NSIndexPath *) indexPath {return CGSizeMake (50, 50); } 그리고 indexPath를 기반으로 크기를 전달하십시오. – kaushal

답변

0

UICollectionViewDataSource

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 

셀의 크기를 가변 indexPath.row위한 switch을 만들고 세트에서 :

cell.frame = CGMake(height: myHeight; width: myWidth) 
관련 문제