如何在SwiftUI中设置SF符号的大小?

时间:2019-08-03 21:19:16

标签: swiftui sf-symbols

如何使用SwiftUI在Xcode 11中设置SF符号的大小?

3 个答案:

答案 0 :(得分:9)

SF符号类似于字体,因此:

.font(.system(size: 60))

答案 1 :(得分:9)

一种替代方法是使用.imageScale()

Image(systemName: "chevron.left").imageScale(.small)
Image(systemName: "chevron.left").imageScale(.medium)
Image(systemName: "chevron.left").imageScale(.large)

答案 2 :(得分:1)

您可以设置重量和尺寸:

Image(systemName: "checkmark.circle")
    .font(.system(size: 16, weight: .ultraLight))
Image(systemName: "checkmark.circle")
    .font(.system(size: 16, weight: .thin))
Image(systemName: "checkmark.circle")
    .font(.system(size: 16, weight: .light))
Image(systemName: "checkmark.circle")
    .font(.system(size: 16, weight: .regular))
Image(systemName: "checkmark.circle")
    .font(.system(size: 16, weight: .medium))
Image(systemName: "checkmark.circle")
    .font(.system(size: 16, weight: .semibold))
Image(systemName: "checkmark.circle")
    .font(.system(size: 16, weight: .bold))
Image(systemName: "checkmark.circle")
    .font(.system(size: 16, weight: .heavy))
Image(systemName: "checkmark.circle")
    .font(.system(size: 16, weight: .black))