Expectations were always going to be high for SwiftUI this year, but the team didn’t disappoint – they’ve shipped a massive collection of improvements and features, including a new AsyncImage view for loading remote images, swipe actions for list rows, pull to refresh, plus shorter, simpler APIs for common uses.

An important animation deprecation

The one-parameter form of the animation() modifier has now been formally deprecated, mostly because it caused all sorts of unexpected behaviors.

That seems simple enough: animation the text getting larger or smaller when it’s tapped. However, the animation is attached to everything for the label, which means even something like rotating the screen would make the text label animate from its old position to its new position.

Toggle buttons

iOS 15 provides a middle ground between Button and Toggle, which is a Toggle that looks like a button but flips its foreground and background colors in its on state. This is enabled using the .button toggle style.

Automatic image selection for TabView

In iOS 15 SwiftUI now automatically selects the correct variant of an SF Symbols icon when used inside a TabView.

According to the iOS human interface guidelines icons ought to be filled when used inside a TabView, but according to the macOS human interface guidelines they should be stroked. To make this work well on both platforms, you can now specify the simple, unfilled form of the image and have SwiftUI use the correct variant as appropriate for the platform.

Primary actions for menus

In iOS 15 menus can also have a primary action attached, which is triggered when the menu’s button is tapped rather than held down. So, you press and release to trigger the primary action, or hold down to get the full menu of options.

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,