【发布时间】:2021-01-06 22:01:09
【问题描述】:
我有一张图片,我正在对尺寸进行硬编码,但我意识到它不会针对更大尺寸的类别进行缩放。如何设置首选尺寸并让它自动放大到不同的尺寸?
这是我的代码的样子:
HStack(alignment: .top, spacing: 4) {
Text("Some text")
Button(action: { showAlert = true }) {
Image(systemName: "questionmark.circle.fill")
.resizable()
.frame(width: 12, height: 12)
.foregroundColor(.secondary)
}
}
我还有其他不使用 SF 符号的情况:
Button(action: action) {
Label(
title: {
Text(title)
.foregroundColor(Color(.label))
},
icon: {
Image("twitter")
.resizable()
.frame(width: 24, height: 24)
}
)
}
这是它在不同尺寸的预览中的样子,但在较大的比例下图像很小。我该如何处理以实现可访问性?
【问题讨论】:
标签: swiftui accessibility