ycliper

Популярное

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

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

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

Топ запросов

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

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

Автор: Kodeco

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

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

Описание: In this episode, you'll learn how to replicate a Pinterest layout using collection views.

----
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 в вашей сети.
Повторяем попытку...
Pinterest Basic Layout - Custom Collection View Layouts in iOS - raywenderlich.com

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

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

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

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

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

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

Pinterest Basic Layout - Layout Attributes - Custom Collection View Layouts - raywenderlich.com

Pinterest Basic Layout - Layout Attributes - Custom Collection View Layouts - raywenderlich.com

Композиционный макет CollectionView (расширенные макеты) — Swift 5, Xcode 12, 2020 — Разработка п...

Композиционный макет CollectionView (расширенные макеты) — Swift 5, Xcode 12, 2020 — Разработка п...

Sticky Headers  - Custom Collection View Layouts - raywenderlich.com

Sticky Headers - Custom Collection View Layouts - raywenderlich.com

Гайд по UICollectionView и UITableView|Раскрытие элементов, анимация, закругления, тени, скролл

Гайд по UICollectionView и UITableView|Раскрытие элементов, анимация, закругления, тени, скролл

UICollectionView Tutorial: Custom UICollectionView Layout like Pinterest

UICollectionView Tutorial: Custom UICollectionView Layout like Pinterest

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

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

ChatGPT продает ваши чаты, Anthropic создает цифровых существ, а Маск как всегда…

ChatGPT продает ваши чаты, Anthropic создает цифровых существ, а Маск как всегда…

Музыка для работы за компьютером | Фоновая музыка для концентрации и продуктивности

Музыка для работы за компьютером | Фоновая музыка для концентрации и продуктивности

Onboarding with the UIPageViewController (Swift/iOS)

Onboarding with the UIPageViewController (Swift/iOS)

Typst: Современная замена Word и LaTeX, которую ждали 40 лет

Typst: Современная замена Word и LaTeX, которую ждали 40 лет

Parallax Effect - Custom Collection View Layouts - raywenderlich.com

Parallax Effect - Custom Collection View Layouts - raywenderlich.com

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

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

Почему Ядерная война уже началась (А вы не заметили)

Почему Ядерная война уже началась (А вы не заметили)

Swift: Waterfall CollectionView Layout (2021, Xcode 12, Swift 5) - iOS Development

Swift: Waterfall CollectionView Layout (2021, Xcode 12, Swift 5) - iOS Development

LLM и GPT - как работают большие языковые модели? Визуальное введение в трансформеры

LLM и GPT - как работают большие языковые модели? Визуальное введение в трансформеры

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

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

NotebookLM: большой разбор инструмента (12 сценариев применения)

NotebookLM: большой разбор инструмента (12 сценариев применения)

Почему работает теория шести рукопожатий? [Veritasium]

Почему работает теория шести рукопожатий? [Veritasium]

Swift: How to UICollectionView Flow Layout

Swift: How to UICollectionView Flow Layout

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

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

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



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



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