I’m trying to set a custom font in my SwiftUI Text view. Here is the code I’m using:
struct SampleView: View {
var body: some View {
Text("Hello, World!")
.font(.custom("custom-font", size: 20)) // 1
.font(Font.custom("custom-font", size: 20)) // 2
}
}
The first line works correctly, but the second line doesn’t. I expected both to function the same since the first line is a shorthand for the second line.
Can someone explain why the second might not be working in this context?