在SwiftUI中显示工作表后,交互式UI元素的文本颜色变为systemBlue?

问题描述 投票:0回答:1

我有一个按下按钮时会显示的工作表:

struct Button: View {
    @State isPresented = false
    var body: some View {
        Button(action: { self.isPresented.toggle() },
        label: { Text("Text Label") }
        ).sheet(isPresented: $isPresented, content: { 
            //sheet contents in here
        })
    }
}

[呈现工作表然后将其关闭时,它会使其他UI元素(例如,文本按钮)的文本颜色变为systemBlue UIColor ...您知道如何解决此问题吗?

swift swiftui uicolor
1个回答
0
投票

没有提供足够的代码来测试,但是原因可能在

struct Button: View { // << this custom view named as standard Button !!!
    @State isPresented = false

它的名称与标准SwiftUI组件Button相同,因此这可能会使渲染引擎感到困惑。

尝试将此名称重命名(以及其他如果您使用此名称,则重命名)为应用程序独有的名称,例如MyButtonCustomButtonSheetButton等]

© www.soinside.com 2019 - 2024. All rights reserved.