Lor*_*rri 4 label toolbar button swift swiftui
我创建了一个视图,显示一个按钮,其中有一个带有名称和图标的标签。
struct NewWordButtonView: View {
@State var isAlert: Bool = false
var body: some View {
Button {
isAlert.toggle()
} label: {
Label("change word", systemImage: "arrow.triangle.2.circlepath").fixedSize()
}
.buttonStyle(.bordered)
}
}
Run Code Online (Sandbox Code Playgroud)
它应该看起来像这样:
但是,当我将视图添加到工具栏中作为工具栏项时,文本消失,仅保留图标。像这样:
有什么建议吗?
titleAndIcon
将标签样式设置为您的label
,这将确保显示标签的标题和图标。
Label("change word", systemImage: "arrow.triangle.2.circlepath")
.labelStyle(.titleAndIcon)
.fixedSize()
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
610 次 |
最近记录: |