SwiftUI 工具栏文本在显示时更改大小。

4

这个问题相关。

Gif

我正在尝试制作一个基于“备忘录”应用的应用程序。

我将我的iPhone文本大小设置为最小,在视图更改时,新视图工具栏上的文本变得更大。

代码:

.toolbar {
        ToolbarItem(placement: .navigationBarTrailing) {
            HStack {
                Button {
                    parentList.starred.toggle()
                } label: {
                    Label("Toggle Favorite", systemImage: parentList.starred ? "star.fill" : "star")
                        .labelStyle(.iconOnly)
                        .foregroundColor(parentList.starred ? .yellow : .gray)
                }
                
                Button(action: editList) {
                    Label("Edit List", systemImage: "ellipsis.circle")
                }
                
                EditButton()
            }
        }
        
        ToolbarItem(placement: .bottomBar) {
            Spacer()
        }
        
        ToolbarItem(placement: .status) {
            if parentList.childvocabularies!.count == nil {
                Text("")
                    .foregroundColor(.secondary)
                    .font(.caption)
            }
            else if parentList.childvocabularies!.count == 1{
                Text("\(parentList.childvocabularies!.count) Vocabulary")
                    .foregroundColor(.secondary)
                    .font(.caption)
            } else {
                Text("\(parentList.childvocabularies!.count) Vocabularies")
                    .foregroundColor(.secondary)
                    .font(.caption)
            }
        }
        
        ToolbarItem(placement: .bottomBar) {
            Button(action: addItem) {
                Label("Add Item", systemImage: "plus")
            }
        }
    }

这是个bug吗?

2个回答

2

这个问题已经在iOS 16测试版中得到解决。


0

虽然这会引入其他问题(比如更改左边距),但你可以尝试:

Text("ACCOUNT")
    .font(.boldFont(size: 14))
    .minimumScaleFactor(0.5)
    .fixedSize(horizontal: true, vertical: false)

最小比例因子防止字体大小增加,固定大小防止文本被截断。粗体字是我们的自定义扩展,使我们的自定义字体加粗。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接