2017-11-01 8 views
-3

私collectionviewはこのようにアウトを開始:ユーザーが、それはそうのように展開するコレクション上にスワイプするとき initial screenコレクションビューのセルのサイズを変更するにはどうすればよいですか?

:コレクションビューを展開したときに second screen

は、どのように私は、セルのサイズを変更できますか?英語で

+3

[SwiftでUICollectionViewCellのサイズをプログラムで変更する方法](https://stackoverflow.com/questions/31662155/how-to-change-uicollectionviewcell-size-programmatically-in-swift) ) –

答えて

0

:あなたはセルの高さを設定する必要が

は、コレクションビューの高さに等しく、毎回のコレクションでは、レイアウトを更新する必要がありますサイズを変更。

はあなたのビューコントローラUICollectionViewDelegateFlowLayout

に準拠し、細胞のサイズを変更する

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize

を使用する必要がiOSの言語で

extension YourViewController: UICollectionViewDelegateFlowLayout { 

    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { 


     let height = collectionView.frame.size.height 
     let width = //make your calculation 

     return CGSize(width: width, height: height) 
    } 
} 

このようなもの

関連する問題