I have this weird issue. When I click the ColorPicker, the view dismissed and pop back to the root view. I have attach a screen record below. Anyone have idea how to fix this issue?
The code run on simulator ios 15.2
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
TabView {
HomePageView()
.tabItem {
Label("Home", systemImage: "circle.grid.cross.fill")
}
ProfileView()
.tabItem {
Label("Profile", systemImage: "person.fill")
}
}
.background(.secondary)
}
}
}
struct HomePageView: View {
var body: some View {
Text("Home View")
}
}
struct ProfileView: View {
var body: some View {
NavigationLink {
ColorPickerView()
} label: {
Text("Color Picker View")
}
}
}
struct ColorPickerView: View {
@State var bgColor = Color.blue
var body: some View {
ColorPicker("Pick color", selection: self.$bgColor)
.padding(.horizontal, 15)
}
}