ios – UICollectionView content material hidden by TabBar

0/5 No votes

Report this app

Description

[ad_1]

The issue

Hiya, group! I created a UICollectionView programmatically and wish it to show pictures that take the total measurement of the display screen, surpassing the highest secure space however respecting the underside secure space, since on the backside I’ve TabBar. The problem with the present UI is that I obtained it to disregard the highest secure space, however the tab bar hides a part of the content material for the reason that assortment takes the dimensions of the entire display screen (Video). I am attempting in order that my UI seems just like the TikTok residence web page the place the collectionView ends when the tab bar begins.

My Code

In ViewDidLoad:

let structure = UICollectionViewFlowLayout()
self.edgesForExtendedLayout = UIRectEdge.backside
structure.scrollDirection = .vertical
structure.itemSize = CGSize(width: view.body.measurement.width, top: view.body.measurement.top)
structure.minimumInteritemSpacing = 0
structure.minimumLineSpacing = 0
collectionView = UICollectionView(body: .zero, collectionViewLayout: structure)
collectionView?.register(PostCollectionViewCell.self, forCellWithReuseIdentifier: PostCollectionViewCell.identifier)
collectionView?.isPagingEnabled = true
collectionView?.dataSource = self
collectionView?.showsVerticalScrollIndicator = false
collectionView?.showsHorizontalScrollIndicator = false
view.addSubview(collectionView!)

In ViewDidLayoutSubviews:

collectionView?.contentInsetAdjustmentBehavior = .by no means
collectionView?.body = view.bounds

What I’ve tried

structure.itemSize = CGSize(width: view.body.measurement.width, top: view.body.measurement.top - (self.tabBarController?.tabBar.body.top)!)

Substracting top of tabBar to CollectionViewFlowLayout

collectionView?.contentInset = UIEdgeInsets(high: 0, left: 0, backside: self.tabBarController!.tabBar.body.top, proper: 0)
collectionView?.contentSize = CGSize(width: view.body.measurement.width, top: view.body.measurement.top - self.tabBarController!.tabBar.body.top)

Many Thanks!

[ad_2]

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.