Reading time: 2 min

This article is a cheatsheet for using system images/icons (SF Symbols) in SwiftUI. It shows all the ways to set their size, color and variants. The end results look like this:

combined

Basics

System images or system icons refer to images that are present by default on Apple platforms. The image co...

Continue Reading...

Reading time: 1 min

This recipe shows how to implement an orientation stack in SwiftUI. This stack will lay out its content along the main screen axis - vertical or horizontal. In other words, it's a VStack if your phone is in portrait mode and an HStack if it's in landscape. The end result looks like this:

preview

...

Continue Reading...

Reading time: 1 min

This recipe shows how to detect device orientation in SwiftUI. You can also use a binding to detect orientation changes. The end result looks like this:

preview

The recipe relies on listening to UIDevice.orientationDidChangeNotification notifications, which are automatically posted whenever device...

Continue Reading...

Reading time: 1 min

This recipe shows how to get haptic feedback when touching SwiftUI views. The end result can't really be conveyed with an image, but here's what the test setup looks like:

Screenshot%202022-04-10%20at%2013.59.54

You can achieve this by triggering UIImpactFeedbackGenerator's impactOccurred method whenever your view is tapped. On...

Continue Reading...

Reading time: 1 min

This recipe shows how to manage status bar in SwiftUI - set background color and material, as well as how to show and hide it. The end result looks like this:

preview

You can change the status bar's color and material by inserting a small view right behind it. Normally, all views are positioned belo...

Continue Reading...