LoginSignup
0
1

More than 5 years have passed since last update.

viewDidAppear後にUICollectionReusableView/Headerの縦サイズを変更する

Last updated at Posted at 2017-08-18

stackoverflowにも書いちゃったけど自己解決。
https://stackoverflow.com/questions/45747953/when-uicollectionviewflowlayout-is-used-can-i-change-the-vertical-size-of-the-h

func collectionView(_ collectionView: UICollectionView,layout collectionViewLayout: UICollectionViewLayout,referenceSizeForHeaderInSection section: Int) -> CGSize {
が最初によばれるでしょ。
困るわー

storyboardでUICollectionViewにtag=1しておくこと

class testo: UIViewController,UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout {
var xxx:CGFloat=1000
.
.
override func viewWillAppear(_ animated: Bool) {
}
override func viewDidAppear(_ animated: Bool) {
    xxx=2000
    let aa = self.view.viewWithTag(1) as! UICollectionView
    aa.reloadData()
}

func collectionView(_ collectionView: UICollectionView,
                    layout collectionViewLayout: UICollectionViewLayout,
                    referenceSizeForHeaderInSection section: Int) -> CGSize {
    return CGSize(width:self.view.frame.width, height:xxx)
}
0
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1