I'm trying to create this relationship that the pictures below depict of Parent -> Children -> Children -> etc. . . I'm trying to use a vertical collection view for the Parent collection view and then nested horizontal collection views for the children. But I'm struggling with moving the collection views cells down when the “View Children Button” is clicked. I thought I could do something like this when the button is clicked:
@IBAction func showChildrenBtnClicked(_ sender: Any) {
collectionView.contentInset.bottom = 200
collectionView.reloadData()
}
but this doesn't seem to do anything. Does anyone know how to add empty space inside the collection view so that I could then create a horizontal collection view to hold the children elements.
These are some mock images of the behavior I'm trying to achieve:
Thank you in advance.
First take all the view as collection view. When ViewchildrenButton get tapped, delegate it to the parent collection view controller class, and there
if let flowLayout = metaMoreCollectionView.collectionViewLayout as? UICollectionViewFlowLayout {
flowLayout.invalidateLayout()
}
This will call the
collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize
and give the updated size there.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.