AlbertB
AlbertB

Reputation: 637

UICollection header full in iphone x

I'm working in a UICollectionViewand I'm using the "Setion Header" option, everything is working fine except that in landscape mode the iPhone X does not fill completely.

I tried to find a solution for example with this but it does not work for me:

    if #available(iOS 11.0, *) {
        myCollection?.contentInsetAdjustmentBehavior = .always
    }

Any suggestions on this?

In portraid it looks good:

my collection app

PORTRAID

Order of my views:

views

Upvotes: 3

Views: 370

Answers (2)

Amit
Amit

Reputation: 4896

You can use size classes for it.

In Storyboard click on view as at the bottom :

enter image description here

and change the orientation to landscape.

Select the trailing constraint of collectionView :

enter image description here enter image description here

introduce the variation for the constraint for compact-compact as -44.

enter image description here

The final UI will be :

enter image description here

Repeat the same process for leading constraint. Hope it helps what you want to achieve here. Happy coding

Edit

Googled and got the same question in SO:

May be this helps what you want to achieve.

Upvotes: 2

Chanchal Chauhan
Chanchal Chauhan

Reputation: 1560

Remove Leading trailing constraints and add Leading and trailing constraints 0 from view not from safe area for your collection view.

enter image description here

Upvotes: 1

Related Questions