SwiftUI IcontFont使用记录

2020-11-19  本文已影响0人  fordG
<key>UIAppFonts</key>
    <array>
        <string>iconfont.ttf</string>
    </array>
image.png
public enum IconFont: String {
    case version = "\u{e672}"
    case info = "\u{e61e}"
    case more = "\u{e63a}"
    case attachment = "\u{e607}"
    case copy = "\u{ef86}"
    case dot = "\u{e608}"
    case back = "\u{e603}"
}

Text(IconFont.back.rawValue)
            .font(.custom("iconfont", size: 20))

总结下:

  1. 倒入iconfont文件
  2. infoplist加入倒入文件的名字
  3. 枚举各个icon的类型
  4. 使用 .font(.custom)来展示, 你也可以自己封装一下,方便使用
上一篇 下一篇

猜你喜欢

热点阅读