Created
April 4, 2017 10:28
-
-
Save Athosone/9b0bfabff8ab90ded365f52af857299f to your computer and use it in GitHub Desktop.
Calculate size of uicollectionview
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { | |
guard let dummyCell: OABSubCategoryMenuCell = Bundle.main.loadNibNamed("OABSubCategoryMenuCell", owner: self, options: nil)?.first as? OABSubCategoryMenuCell else { | |
return CGSize.zero | |
} | |
dummyCell.setContent(subCat: self.subCategories[indexPath.row], isSelected: false) | |
dummyCell.setNeedsLayout() | |
dummyCell.layoutIfNeeded() | |
let size: CGSize = dummyCell.contentView.systemLayoutSizeFitting(UILayoutFittingCompressedSize) | |
return size | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment