#swiftui

Found 25 articles tagged with #swiftui

Using custom environment values in SwiftUI

Custom environment values are useful when you have data that multiple views need access to, but you don't want to pass them down manually through each view's initializer.

Apr 25, 2024#swiftui

How to config launch screen in SwiftUI

Launch screen is the initial screen that appears when your app is launched. It provides a seamless transition from launching the app to displaying its first screen.

Apr 22, 2024#swiftui

Hiding the keyboard when scrolling in SwiftUI

For most cases, using the scrollDismissesKeyboard modifier is the simpler and more recommended approach, especially with SwiftUI 16 and later.

Apr 21, 2024#swiftui

StateObject vs ObservedObject in SwiftUI

Use StateObject when the view is the source of truth for the object, ObservedObject when the object’s lifecycle is managed outside the view, such as when it’s passed into the view.

Apr 18, 2024#swiftui

How to dismiss a sheet in SwiftUI

There are several ways to dismiss views in SwiftUI like using a @Binding variable, dismiss environment value or deprecated presentationMode.

Jan 07, 2024#swiftui

How to perform migrations in SwiftData

Lightweight migrations are automatic and can handle small changes, complex migrations require manual intervention and can handle more advanced changes.

How to create custom view modifiers in SwiftUI

You can also create your own custom view modifiers by adopting the ViewModifier protocol and implementing the body(content:) method.

Jan 04, 2024#swiftui#modifiers

Difference between Binding and Bindable in SwiftUI

Binding creates a two-way connection, while Bindable create bindings to the mutable properties of an observable object.

How to resize image and keep aspect ratio in SwiftUI

By understanding the different content modes and how to use custom aspect ratios, you can ensure your images look great on all devices and screen orientations.

Dec 03, 2023#swiftui#images

How to Pass Data Up & Down in SwiftUI

In SwiftUI, choose one source of truth, then pass data down with properties or environment, pass editable values with bindings, and pass child-derived values up with preferences.

Mar 24, 2023#how-to#swiftui