2017-05-05 21 views

답변

1

UICollectionViewDelegateFlowLayout에서 sizeForItemAt indexPath 메서드를 사용할 수 있습니다. 이렇게하면 각 셀의 크기가 결정되며 다른 요소의 크기 (예 : view)와 상대적으로 구성 할 수 있습니다.

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { 
    return CGSize(width: view.frame.width/2, height: 50) 
} 

그냥 컬렉션보기의 deleagte이 설정되어 있는지 확인하고, 대리인은 UICollectionViewDelegateFlowLayout 프로토콜을 준수합니다.