Reading time: 1 min

This quick recipe shows how to display an image from Assets catalog in SwiftUI.

Say that you've added your image to the Assets catalog:

Screenshot%202022-03-08%20at%2020.50.32

All you have to do to render it on the screen is to pass its name to Image:

Image("logo_small")

Screenshot%202022-03-09%20at%2009.53.10

Using Image(decorative:) does the same thing.

Continue Reading...

Reading time: 4 min

This recipe shows how to pause and resume animations in SwiftUI. The end result looks like this:

Preview

This component is available as a Swift Package in this repo.

Pausing and stopping animations

Stopping an animation in SwiftUI, while not available out of the box, is fairly easy. What y...

Continue Reading...

Reading time: 2 min

This recipe shows how to implement a marquee - self-scrolling content that goes across the screen - in SwiftUI. You'll be able to control the speed and direction of the animation, as well as if it reverses or resets once it ends. The end result looks like this:

preview

Recipe

This recipe relie...

Continue Reading...

Reading time: 2 min

This recipe shows how to track SwiftUI animation progress and completion via callbacks. For an animated value (offset, opacity, etc.), get its current value as the animation progresses and then get notified when the animation is completed. The end result looks like this:

Preview

This component is av...

Continue Reading...

Reading time: 2 min

This recipe shows how to present a custom view modally from anywhere in the SwiftUI app. Normally, presenting a view on top of another one forces you do define the transition in the parent view. This solution, however, makes it so that the segue is defined in just a single place and is always p...

Continue Reading...