Text()
ã®ãã©ã³ãæå®ã«UIFontã使ããªãã£ããã©ããããããã®ãï¼
å®è¡ç°å¢
- Xcode 11.6
- iOS 13.6
åé¡ã®æå
UIFont.futuraMediumFont(ofSize:)
ã®ããã«ã«ã¹ã¿ã ãã©ã³ãã使ããããããã¦ã¼ãã£ãªãã£ã¯ã©ã¹ãä½æãã¦ããã
import UIKit extension UIFont { static func futuraMediumFont(ofSize size: CGFloat) -> UIFont { return UIFont(name: "Futura-Medium", size: size) ?? UIFont.systemFont(ofSize: size, weight: .medium) } }
ãã®ãã©ã³ããä¸è¨ã®ããã«Textã®ãã©ã³ãæå®ã«ä½¿ãããã£ãããã«ãã¨ã©ã¼ãçºçããã
Text(R.string.localizable.home_title()).font(UIFont.futuraMediumFont(ofSize: 22)
解決編
SwiftUIã§ã¯ UIFontã¯ä½¿ããªãã®ã§ããããã« Fontã¯ã©ã¹ã使ãã
import SwiftUI extension Font { static func futuraMedium(size: CGFloat) -> Font { return Font.custom("Futura-Medium", size: size) } }