Today's lesson will cover the topic of using View Modifiers to clean up a bunch of repetitive code in SwiftUI.
Redacted modifier is the thing that will have a great impact on how iOS apps handle loading states. During WWDC20, Apple showed us the easy way of hiding the data from home-screen widgets using the redacted modifier. Today we will talk about using the redacted modifier to hide sensitive data and handle loading states.
You may have seen some examples of fixed size modifier usage while trying to fix the issue with multiline text in SwiftUI. But do you know what exactly fixed size modifier does? How does it work? Today I want to talk about all the magic and power behind the fixed size modifier.
ViewModifiers play a significant role in SwiftUI. Most of the functions called on a View are ViewModifiers. It is the primary way of modifying the view instance in SwiftUI. In this post, we will take a look at some ready to use ViewModifiers, and then we will build our own custom ViewModifier.
You probably already know you can use ViewModifier and custom Views to encapsulate some of that code. And although that helps, today we will talk about a slightly different way of reusability, that can lead to even more readable code: extensions to the View protocol.
If you find yourself constantly attaching the same set of modifiers to a view – e.g., giving it a background color, some padding, a specific font, and so on – then you can avoid duplication by creating a custom view modifier that encapsulates all those changes