SwiftUI PreferenceKeys
Автор: Stewart Lynch
Загружено: 2023-05-21
Просмотров: 5162
In this tutorial, I am going to introduce you to SwiftUI PreferenceKeys. If you've been creating SwiftUI applications for a while, you might have been using them without even realizing it.
Firstly, I will explain what a preferenceKey is and demonstrate how you have been utilizing them in your own projects since the early stages of SwiftUI development. It's fascinating to discover the hidden power behind these essential tools.
Next, I will delve into the structure and requirements for creating custom PreferenceKeys. I'll guide you through the process and show you how to utilize the Reduce function to send information up your view hierarchy instead of the traditional approach of passing down variables through the environment.
To make things more practical and engaging, I will provide four examples throughout the video. Some of these examples may seem contrived, but they serve the purpose of showcasing the true potential of preference keys. You'll gain a solid understanding of their capabilities and how they can be effectively integrated into your own applications.
By the end of this tutorial, you'll have a clear grasp of SwiftUI PreferenceKeys and the immense value they bring to your development workflow.
If you want to support my work, you can buy me a coffee :)
https://ko-fi.com/stewartlynch
Table of Contents:
0:00 Introduction
1:06 The NavigationTitle PreferenceKey
4:21 Example 1
11:04 Example 2
15:18 Example 3 - Practical Reduce Function
17:11 Example 4 - With GeometryReader
Starter Project Files:
(If you are having problems downloading zip files, use Safari. Chrome restricts zip files by default)
https://www.createchsol.com/StarterPr...
Completed Project:
https://github.com/StewartLynch/Swift...
References mentioned in video:
Custom Environment Values in SwiftUI
• Custom Environment Values in SwiftUI
Other References:
Stewart Lynch's YouTube Channel:
/ @stewartlynch
Stewart Lynch on Mastodon:
https://iosdev.space/@StewartLynch
Stewart Lynch on Twitter:
/ stewartlynch
Stewart Lynch on LinkedIn
/ stewartlynch
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: