简体   繁体   中英

How to put UIView inside of UICollectionView?

I want to put my UIView inside of UICollectionView(on top) that on scroll it scrolls with UICollectionView content. It's possible to put it on header part in UITableView, I did it, but in UICollectionView I cannot achieve the same effect. How can I do it?

I have created GitHub repo with sample . If anyone could help me with it.

In UITableView I add UIView inside of UITableView and it stays there, but in UICollectionView it stays behind of UICollectionView. I want that it(UICollectionView sections) will stay under the UIView and on scroll all(UIView & UICollectionView sections) will scroll together.

There is no such thing as collection view footer or header, because the layout can be very different depending on your needs, but, you have a couple of function that can help you for example: registerClass(_:forSupplementaryViewOfKind:withReuseIdentifier:)

or

registerNib(_:forSupplementaryViewOfKind:withReuseIdentifier:)

depending if you are using a nib file or not.

I'm not sure but you will also need to provide the height of the view in the layout delegate UICollectionViewDelegateFlowLayout

you can do this by dragging your UIView on to your cellidentifier of UICOllectionView Like i did see in snapshot: 在此处输入图片说明

here View is my UIView which i added to UICollectionView and it scroll with the CollectionView

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM