Final words on the custom layout

The custom layout you created in this subsection is an excellent example of how powerful collection views are. However, with great power comes great responsibility. For instance, you will need to make sure your layout is as performant as you can make it. Slower implementations will quickly lead to lousy scrolling performance, which you want to avoid at all costs. However, don't go overboard with optimizing your code right away. Think about the use case for your collection view. Maybe you won't ever display more than a certain amount of items, and you can get away with a slightly slower implementation. Or perhaps you want to reuse your layout, meaning you should make sure it works great no matter how many items you throw at it.

Being able to create fantastic collection view layouts is a skill you will most certainly want to have as it enables you to implement amazing, performant layouts that will delight your users. You know now that creating your collection view layout does not have to be extremely complex. With some careful planning and experimentation in playgrounds, you will build amazing layouts for your users in no time!

Reader exercise: The layout you created is aligned to the top of the collection view and fills the screen up as much as possible. This leaves empty space at the bottom of the screen. Try to adapt the layout so that it's centered vertically, making sure the space up top matches the space at the bottom. Implementing this will involve updating your layout preparation and invalidation code. Good luck!
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset