ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

Custom Collection View Layouts in iOS: Introduction - raywenderlich.com

Автор: Kodeco

Загружено: 2017-03-15

Просмотров: 15376

Описание: In this video series, you'll learn about the basics of creating layouts using collection views. This series will cover some layouts used in some really popular apps.

----
About www.raywenderlich.com:

raywenderlich.com is a website focused on developing high quality programming tutorials. Our goal is to take the coolest and most challenging topics and make them easy for everyone to learn – so we can all make amazing apps.

We are also focused on developing a strong community. Our goal is to help each other reach our dreams through friendship and cooperation. As you can see below, a bunch of us have joined forces to make this happen: authors, editors, subject matter experts, app reviewers, and most importantly our amazing readers!
----

From Apple Developer Docs:

A collection view is a way to present an ordered set of data items using a flexible and changeable layout. The most common use for collection views is to present items in a grid-like arrangement, but collection views in iOS are capable of more than just rows and columns. With collection views, the precise layout of visual elements is definable through subclassing and can be changed dynamically, so you can implement grids, stacks, circular layouts, dynamically changing layouts, or any type of arrangement you can imagine.

Collection views keep a strict separation between the data being presented and the visual elements used to present that data. In most cases, your app is solely responsible for managing the data. Your app also provides the view objects used to present that data. After that, the collection view takes your views and does all the work of positioning them onscreen. It does this work in conjunction with a layout object, which specifies the placement and visual attributes for your views and that can be subclassed to fit your app’s exact needs. Thus, you provide the data, the layout object provides the placement information, and the collection view merges the two pieces together to achieve the final appearance.

Creating Custom Layouts

Before you start building custom layouts, consider whether doing so is really necessary. The UICollectionViewFlowLayout class provides a significant amount of behavior that has already been optimized for efficiency and that can be adapted in several ways to achieve many different types of standard layouts. The only times to consider implementing a custom layout are in the following situations:

The layout you want looks nothing like a grid or a line-based breaking layout (a layout in which items are placed into a row until it’s full, then continue on to the next line until all items are placed) or necessitates scrolling in more than one direction.

You want to change all of the cell positions frequently enough that it would be more work to modify the existing flow layout than to create a custom layout.

The good news is that, from an API perspective, implementing a custom layout is not difficult. The hardest part is performing the calculations needed to determine the positions of items in the layout. When you know the locations of those items, providing that information to the collection view is straightforward.

Tips for Implementing Your Custom Layouts

Here are some tips and suggestions for implementing your custom layout objects:

Consider using the prepareLayout method to create and store the UICollectionViewLayoutAttributes objects you need for later. The collection view is going to ask for layout attribute objects at some point, so in some cases it makes sense to create and store them up front. This is especially true if you have a relatively small number of items (several hundred) or the actual layout attributes for those items change infrequently.

If your layout needs to manage thousands of items, though, you need to weigh the benefits of caching versus recomputing. For variable-size items whose layout changes infrequently, caching generally eliminates the need to recompute complex layout information regularly. For large numbers of fixed-size items, it may just be simpler to compute attributes on demand. And for items whose attributes change frequently, you might be recomputing all the time anyway so caching may just take up extra space in memory.

Avoid subclassing UICollectionView. The collection view has little or no appearance of its own. Instead, it pulls all of its views from your data source object and all of the layout-related information from the layout object. If you are trying to lay out items in three dimensions, the proper way to do it is to implement a custom layout that sets the 3D transform of each cell and view appropriately.

Never call the visibleCells method of UICollectionView from the layoutAttributesForElementsInRect: method of your custom layout object. The collection view knows nothing of where items are positioned, other than what the layout object tells it. So asking for the visible cells is just going to forward the request to your layout object.

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
Custom Collection View Layouts in iOS: Introduction - raywenderlich.com

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

Pinterest Basic Layout - Custom Collection View Layouts in iOS - raywenderlich.com

Pinterest Basic Layout - Custom Collection View Layouts in iOS - raywenderlich.com

Как создать приложение — Урок 1 (обновлённый Xcode 16)

Как создать приложение — Урок 1 (обновлённый Xcode 16)

Идеи PET-проектов для Junior iOS-developer

Идеи PET-проектов для Junior iOS-developer

Multiple Sections in CollectionView (Swift 5)

Multiple Sections in CollectionView (Swift 5)

ДЕНЬ 1443. ПАНИКА В ВОЙСКАХ РФ: МАСК ВЫКЛЮЧИЛ СТАРЛИНКИ/ ПЕРЕГОВОРЫ/ КРИЗИС НЕДВИЖИМОСТИ В РФ

ДЕНЬ 1443. ПАНИКА В ВОЙСКАХ РФ: МАСК ВЫКЛЮЧИЛ СТАРЛИНКИ/ ПЕРЕГОВОРЫ/ КРИЗИС НЕДВИЖИМОСТИ В РФ

Введение в автоматическую компоновку в iOS, Эпизод 2: Interface Builder и автоматическая компоновка

Введение в автоматическую компоновку в iOS, Эпизод 2: Interface Builder и автоматическая компоновка

То, что Китай строит прямо сейчас, лишит вас дара речи

То, что Китай строит прямо сейчас, лишит вас дара речи

Нейронка, которая УНИЧТОЖИЛА ChatGPT 5! / Обзор бесплатной нейросети и ее возможности

Нейронка, которая УНИЧТОЖИЛА ChatGPT 5! / Обзор бесплатной нейросети и ее возможности

Build a Real iOS App From Scratch: A Workshop for Beginners From Kodeco and David Okun

Build a Real iOS App From Scratch: A Workshop for Beginners From Kodeco and David Okun

Лучший Гайд по Kafka для Начинающих За 1 Час

Лучший Гайд по Kafka для Начинающих За 1 Час

Кастомная анимация перехода (Swift 5)

Кастомная анимация перехода (Swift 5)

Smoke Mood — Just Relax | Deep House Mix 2026 • Chill / Night Vibes / Stress Relief  #3

Smoke Mood — Just Relax | Deep House Mix 2026 • Chill / Night Vibes / Stress Relief #3

Руководство по ESP32 2024 | Выбор и использование платы ESP32

Руководство по ESP32 2024 | Выбор и использование платы ESP32

21 неожиданный способ использовать Gemini в повседневной жизни

21 неожиданный способ использовать Gemini в повседневной жизни

Introduction to Auto Layout in iOS, Episode 3: Adding Constraints in Interface Builder

Introduction to Auto Layout in iOS, Episode 3: Adding Constraints in Interface Builder

Как учиться быстро и самому? На примере языков  программирования.

Как учиться быстро и самому? На примере языков программирования.

VS Code ПОЛНЫЙ курс + настройка (интерфейс, плагины, работа с кодом)

VS Code ПОЛНЫЙ курс + настройка (интерфейс, плагины, работа с кодом)

Самая сложная модель из тех, что мы реально понимаем

Самая сложная модель из тех, что мы реально понимаем

За пределами анимации с Core Animation — Джон Санделл, Swift by Sundell

За пределами анимации с Core Animation — Джон Санделл, Swift by Sundell

How to Make a CollectionView w/ Custom Cells Programmatically (Swift, UIKit)

How to Make a CollectionView w/ Custom Cells Programmatically (Swift, UIKit)

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]