I am trying to change color of actionSheet's text in SwiftUI. Unable to do so. I tried following code
private var actionSheet: ActionSheet {
let button1 = ActionSheet.Button.default(Text("Week 1").foregroundColor(.orange)) {
self.selectedShuffleWeek = "Week 1"
self.shufflePresented = true
self.actionSheetPresented = false
}
let button2 = ActionSheet.Button.default(Text("Week 2").foregroundColor(Color("GreenColor"))) {
self.selectedShuffleWeek = "Week 2"
self.shufflePresented = true
self.actionSheetPresented = false
}
let button3 = ActionSheet.Button.default(Text("Week 3").foregroundColor(Color("GreenColor"))) {
self.selectedShuffleWeek = "Week 3"
self.shufflePresented = true
self.actionSheetPresented = false
}
let dismissButton = ActionSheet.Button.cancel {
self.selectedShuffleWeek = ""
self.actionSheetPresented = false
}
let buttons = [button1, button2, button3, dismissButton]
return ActionSheet(title: Text("Shuffle"),
buttons: buttons)
}
After that I also tried to change the accent color of the view in which I am showing this action sheet but its not working.
I've managed to get this working by adding the following code in SceneDelegate
inside func scene(_...
UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = Color("GreenColor")
This will change the accent colour of all ActionSheets in your application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With