gpt4 book ai didi

swift - 如何在SwiftUI中更改actionSheet的文本颜色

转载 作者:行者123 更新时间:2023-12-01 05:49:02 24 4
gpt4 key购买 nike

我正在尝试在SwiftUI中更改actionSheet文本的颜色。无法这样做。我尝试了以下代码

    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)
}

之后,我还尝试更改显示此操作表但不起作用的 View 的强调色。

最佳答案

我设法通过在SceneDelegate内的func scene(_...中添加以下代码来使其工作

UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = Color("GreenColor")

这将更改应用程序中所有ActionSheets的强调色。

关于swift - 如何在SwiftUI中更改actionSheet的文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57347423/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com