I'm trying to set a custom default font in my SwiftUI app. I tried several suggestions from this thread Set a default font for whole iOS app?.
However, none of those seem to work with SwiftUI. For example with this approach:
// Constants.swift
struct Fonts {
static var plex = "IBMPlexMono-Text"
}
// FontExtension.swift
extension UILabel {
var substituteFontName : String {
get { return self.font.fontName }
set { self.font = UIFont(name: Fonts.plex, size: 17)! }
}
}
// AppDelegate.swift in didFinishLaunchingWithOptions-function
UILabel.appearance().substituteFontName = Fonts.plex
When I start the app, the custom font appears for a split second and then changes back to the default font by Apple. Why does it change back to Apple's font and how can it be done permanently?
Is it maybe possible with an extension on Text
-View?