我有一个按下按钮时会显示的工作表:
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 ...您知道如何解决此问题吗?
没有提供足够的代码来测试,但是原因可能在
struct Button: View { // << this custom view named as standard Button !!!
@State isPresented = false
它的名称与标准SwiftUI组件Button
相同,因此这可能会使渲染引擎感到困惑。
尝试将此名称重命名(以及其他如果您使用此名称,则重命名)为应用程序独有的名称,例如MyButton
或CustomButton
,SheetButton
等]