How to get the correct frame of UICollectionViewCell in it's subclass

拜拜、爱过 提交于 2019-12-11 08:08:37

问题


I have a UICollectionView and I set it's cellSize in viewDidLoad:

    let cellWidth = self.view.frame.width / 2
    self.collectionViewFlowLayout.itemSize = CGSize(width: cellWidth, height: 100)`

I try to add a gradient layer to my custom UICollectionViewCell. But the frame size is the one I set from storyboard. I can't get the correct, calculated frame size in my UICollectionViewCell subclass's layoutSubviews method.

How am I going to get the correct frame size?

来源:https://stackoverflow.com/questions/27940635/how-to-get-the-correct-frame-of-uicollectionviewcell-in-its-subclass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!