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...

Reading time: 2 min

This recipe shows how to detect user interactions - taps and touches anywhere on the screen - in SwiftUI. The method doesn't interfere with touch events on UI components and can be turned on/off on demand. The end result looks like this:

preview

The recipe

The recipe involves registering a UITa...

Continue Reading...

Reading time: 1 min

This recipe shows how to add a sticky header to a List in SwiftUI. It also allows for a scrolling part of the header, as well as multiple sticky headers. The end result looks like this:

preview

The recipe goes as follows:

  • Use Section(header:) to define the sticky header and the content beneath...

Continue Reading...

Reading time: 1 min

This recipe shows how to tint SwiftUI images in two ways - by setting the template tint or color multiply. The end result looks like this:

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

Let's start by saying that foregroundColor has no effect here. With that out of the way, the recipe depends on what you want to do with the image, since...

Continue Reading...