Sticky Header with SwiftUI
SwiftUI is a powerful declarative framework which allows us to write a UIKit UITableView
in just a few lines of code!
Today, I am going to show you how you can incorporate Picker
, which is SwiftUI’s way of calling UISegmentedControl
, into a List
, to toggle between data.
By the end of this tutorial, you will know how to stick any view in your List
view! Let’s get started!
We all know that in the great Marvel Universe
, there are both male and female characters, so you are going to create a simple List
, to help users toggle between both lists as they scroll down the list seamlessly!
You may start off a brand new project and in your ContentView
, start by adding these lines of code as data to supply into your views.
Next, let’s create a ContentViewModel
as good MVVM
citizens.