SwiftUI 工作表加粗
SwiftUI sheets bolded
当我使用 SwiftUI 显示 sheet 时,所有内容都会变成粗体。如果我轻扫一下,粗体就会消失。
示例:
.navigationBarItems(leading:
Button(action:{
self.isSheetPresented.toggle()
}) {
Text("Display")
}
.frame(width: 25, height: 45)
.sheet(isPresented: $isSheetPresented) {
Textfield("Hello", text: $binding)
})
}
除了申请之外还有没有简单的解决方法
.fontWeight(.regular) or .font(.body)
一切?
PS:运行 Xcode MacOS 11.0 Beta (20A5395g) 上的版本 12.2 beta 3 (12B5035g)
尝试将 sheet 移出 navigationBarItems 并附加到主体内的某个视图,例如
// ... other views
.navigationBarItems(leading:
Button(action:{
self.isSheetPresented.toggle()
}) {
Text("Display")
}
.frame(width: 25, height: 45)
)
...
} // end of NavigationView
.sheet(isPresented: $isSheetPresented) { // << here !!
Textfield("Hello", text: $binding)
}
好的,我做了一些测试:
.navigationBarItems(leading:
Button(action: {self.showingSettings = true}) {
Image(systemName: "gear")
}
//.sheet(isPresented: $showingAddItem, content: {
// AddView(expirations: self.expirations)
,
trailing:
Button(action: {self.showingAddItem = true}) {
Image(systemName: "plus")
}
//.sheet(isPresented: $showingSettings, content: {
// SettingsView()
)
.sheet(isPresented: $showingAddItem, content: {
AddView(expirations: self.expirations)
})
.sheet(isPresented: $showingSettings, content: {
SettingsView()
})
但是这样做后尾按钮不起作用,只有前导按钮
当我使用 SwiftUI 显示 sheet 时,所有内容都会变成粗体。如果我轻扫一下,粗体就会消失。
示例:
.navigationBarItems(leading:
Button(action:{
self.isSheetPresented.toggle()
}) {
Text("Display")
}
.frame(width: 25, height: 45)
.sheet(isPresented: $isSheetPresented) {
Textfield("Hello", text: $binding)
})
}
除了申请之外还有没有简单的解决方法
.fontWeight(.regular) or .font(.body)
一切?
PS:运行 Xcode MacOS 11.0 Beta (20A5395g) 上的版本 12.2 beta 3 (12B5035g)
尝试将 sheet 移出 navigationBarItems 并附加到主体内的某个视图,例如
// ... other views
.navigationBarItems(leading:
Button(action:{
self.isSheetPresented.toggle()
}) {
Text("Display")
}
.frame(width: 25, height: 45)
)
...
} // end of NavigationView
.sheet(isPresented: $isSheetPresented) { // << here !!
Textfield("Hello", text: $binding)
}
好的,我做了一些测试:
.navigationBarItems(leading:
Button(action: {self.showingSettings = true}) {
Image(systemName: "gear")
}
//.sheet(isPresented: $showingAddItem, content: {
// AddView(expirations: self.expirations)
,
trailing:
Button(action: {self.showingAddItem = true}) {
Image(systemName: "plus")
}
//.sheet(isPresented: $showingSettings, content: {
// SettingsView()
)
.sheet(isPresented: $showingAddItem, content: {
AddView(expirations: self.expirations)
})
.sheet(isPresented: $showingSettings, content: {
SettingsView()
})
但是这样做后尾按钮不起作用,只有前导按钮