3

I am trying to create a Font style that is both italic and uppercase. I am also using LocalizedStringKey to set my String. I tried using smallCaps() but this didn't work with italic() as answered HERE and if I try to use uppercased() on the LocalizedStringKey it just sets the key to uppercase rather than the String.

Anyone know a solution?

 extension Font {
    public static let Heading1: Font = system(size: 34, weight: .black, design: .default).italic()
}

Text("HELLO_WORLD").font(.Heading1)
Dan
  • 543
  • 2
  • 13
  • I have also tried Text("HELLO_WORLD".uppercased(with: Locale.current)).font(.Heading1) but this is still just sets the key to uppercase not the string – – Dan Apr 23 '20 at 09:08

1 Answers1

6

Here is a solution. Tested with Xcode 11.4 / iOS 13.4

demo

Text(NSLocalizedString("HELLO_WORLD", comment: "").uppercased())
    .font(.Heading1)

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Asperi
  • 228,894
  • 20
  • 464
  • 690