I want make different background colors for the top and bottom of a list.
When I use UIKIT I Do like this link
Now I use SwiftUI. And I have no idea how can I make this..
thanks!
I want make different background colors for the top and bottom of a list.
When I use UIKIT I Do like this link
Now I use SwiftUI. And I have no idea how can I make this..
thanks!
You can add a UIView
to the header. I have found a height of 400 is large enough to cover the pull down without seeing the top edge.
var body: some View {
NavigationView {
List(data, id: \.self) { data in
Text("\(data)")
}
.onAppear {
let headerView = UIView(frame: CGRect(x: 0, y: -400, width: UIScreen.main.bounds.width, height: 400.0))
headerView.backgroundColor = .lightGray
UITableView.appearance().addSubview(headerView)
}
.navigationBarTitle("Title", displayMode: .inline)
}
}
If you want a different background color below the List then add another UIView
to change the backgroundView:
let backgroundView = UIView()
backgroundView.backgroundColor = .black
UITableView.appearance().backgroundView = backgroundView