How do i set a weight to SF Symbols for iOS 13?

和自甴很熟 提交于 2019-12-01 16:27:42

When using the font modifier, set a weight to the font you're passing

Image(systemName: "arrow.right")
  .font(Font.title.weight(.ultraLight))

For UIKit, symbols can be configured as follows:

UIImage(systemName: "arrow.right",
        withConfiguration: UIImage.SymbolConfiguration(pointSize: 16, weight: .bold))

SwiftUI 1.0

I just wanted to also mention how to change the weight along with a custom font size.

HStack(spacing: 40) {
    Image(systemName: "moon.zzz")
        .font(Font.system(size: 60, weight: .ultraLight))
    Image(systemName: "moon.zzz")
        .font(Font.system(size: 60, weight: .light))
    Image(systemName: "moon.zzz")
        .font(Font.system(size: 60, weight: .regular))
    Image(systemName: "moon.zzz")
        .font(Font.system(size: 60, weight: .bold))
}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!