black friday sale

Flat 10% off on the purchase of any two apps or more. Use coupon code - FESTIVAL10

Grab It Now
Check Mobile App
Read now
Start a Project

Compositional Layouts in Swift

Save

UITableView used UICollectionView for the more complex view and scroll left to right or top to bottom with different presentations where we have used many other UITableViewCell and UICollectionViews. So, in WWDC 2019 apple introduce a Compositional Layout(UICollectionViewCompositionalLayout) which is used to create custom UICollectionViewLayout.

Compositional layouts create with the combination of small layout groups and convert into large complex layout groups. So it will be helpful to create a complex view because it is divided into small views. It divided into four basic building blocks, and it’s a hierarchy that consists of:

Implementation of Compositional Layout:

Let’s explain the compositional layout with the examples as :

Handling Compositional Layout with Multiple Sections:

1.) Let’s create the function which returning UICollectionViewCompositionalLayout and written as :

2. ) Then add the compositional layout to our collection view, add it to the initializer, and written as:

3.) At last, it looks like as:



Handling Compositional Layout with Nested Groups:

1.) Firstly, create the function for UICollectionViewCompositionalLayout as :

2. ) Then add the compositional layout to our collection view as:

3.) At last, run it and it displayed as:

Conclusion

If you have any comments, questions, or recommendations, feel free to post them in the comment section below!

For other blogs, please click here.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.

Michael Urresta

Michael Urresta

Talk to Sales

Global

Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home