Inspecting the View Tree – Part 3: Nested Views

Inspecting the View Tree

Dealing with Preferences for Nested Views In the previous part of this series, we introduced SwiftUI anchor preferences. Now we are finally coming out of the forest. In this last part, we will put everything together. We will also learn how SwiftUI handles preferences of nested views, plus some other uses of Anchor<T>. As usual, … Read more

Inspecting the View Tree – Part 2: AnchorPreferences

Inspecting the View Tree

In the first part of this article, we introduced the use of preferences. These are very useful to communicate information upwards (from children to ancestors). By defining the associated type of our PreferenceKey, we now know that we can put anything we want in there. In this second part, the moment for Anchor Preferences to … Read more

Inspecting the View Tree – Part 1: PreferenceKey

Inspecting the View Tree

With SwiftUI, we normally don’t need to worry about what happens internally on our child views. Each happily does its own thing. However, life is not always normal. When we face these circumstances, SwiftUI provides us with some great tools. Unfortunately, its documentation is brief at best. This three part article tries to put a … Read more

ScrollView – Pull to Refresh

Pull To Refresh

At the time of writing, ScrollView in SwiftUI is not very customizable. A feature many may be missing, is the ability to refresh its contents when the view is pulled. Fortunately, using view preferences, we can manage to add such behaviour. Once we finished coding our new view, using refreshable ScrollViews will be very easy, … Read more

View Extensions for Better Code Readability

When we are writing our view code, we want to make it look as clean as possible. Good indentation, avoiding long lines, clear and meaningful names, etc. It all contributes to code readability. Nevertheless, sometimes it gets out of control and our views become hard to read and ugly to look at. You probably already … Read more

Impossible Grids with SwiftUI

Native support for grids in SwiftUI is finally here. This is made possible by two new views. These are LazyVGrid and LazyHGrid. From now on, when I write Lazy*View, I will be referring to both of them. In this article, we will first cover the basics, but then we will go a little beyond the common grids with … Read more

GeometryReader to the Rescue

GeometryReader

Most of the time, SwiftUI will do its Layout Magic and life will be wonderful. However, there are times (many times), when we require more control over the layout of our custom views. For these moments, we have several tools. The first one we are going to explore is GeometryReader. What the Parent Wants When … Read more

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close