Thank you so much your quick response.
this was my first Question in this Developer Forums.
I really appreciate it!
By the way, I have one more question.
I also want to change background color another view at same time.
How do I change it?
import SwiftUI
struct ColorSettingView: View {
@Environment(.presentationMode) var presentation
let brPlayer = SoundPlayer()
@State private var bgColor = Color.white
var body: some View {
ZStack{
bgColor
.ignoresSafeArea()
VStack {
ColorPicker("Background Color", selection: $bgColor)
Button (action: {brPlayer.brPlay()
self.presentation
.wrappedValue.dismiss()
}, label: {
Image("Quit")
.resizable()
.aspectRatio(contentMode: .fit)
.padding(/@START_MENU_TOKEN@/[.leading, .bottom, .trailing]/@END_MENU_TOKEN@/)
.frame(width: 100.0, height: 100.0)
})
}
}
}
}
struct ColorSettingView_Previews: PreviewProvider {
static var previews: some View {
ColorSettingView()
}
}
//Another View like ContenViewX
struct ContentViewX: View {
let kiPlayer = SoundPlayer()
@State private var bgColor = Color.white
@State var ColorSettingView = false
var body: some View {
ZStack {
// I also want to change this view as same as ColorSettingView
bgColor
.ignoresSafeArea()
VStack {
Button (action: {kiPlayer.kiPlay()
self.ColorSettingView = true}, label: {Image("Setting")
.resizable()
.aspectRatio(contentMode: .fit)
}
)
.sheet(isPresented: $ColorSettingView, content: {
JankenWorldRPS.ColorSettingView()}
)
}
}
}
}
struct ContentViewX_Previews: PreviewProvider {
static var previews: some View {
ContentViewX()
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: