Top Tabs in SwiftUI
Reading time: 1 min
This tutorial shows how to add Android-like top tabs in SwiftUI.
SVG images in SwiftUI
Navigation bar styling in SwiftUI
Reading time: 2 min
This tutorial shows how to style a navigation bar in SwiftUI - changing its background color, text color, as well as styling the status bar.
Focus change in TextField and SecureField
Reading time: 2 min
Detecting if a text field gained or lost focus is not entirely straightforward in SwiftUI.
TextField
constructor has a parameter named onEditingChanged
, but it triggers only when the user taps the return key in the virtual keyboard, not when the focus is actually lost.
Even worse, SecureField
doesn't have such a parameter, and there's no way to know if the user is interacting with the view!
Scrolling ScrollView programatically
Reading time: 1 min
This recipe is about how to scroll a SwiftUI ScrollView
programatically. Here's a quick breakdown of what to do:
- For iOS 13 - tough luck - it can't be done. For whatever reason, this is one of things that were deemed less important for the initial release of SwiftUI.
- For iOS 14 and above - embed your
ScrollView
's root view in aScrollViewReader
, and then use thescrollTo
method.