iosswiftuitypographyxcode11.3smallcaps

Use .smallCaps() in SwiftUI


Im trying to change my text to small caps in SwiftUI. But I don't understand how to apply the Method to my text.

https://developer.apple.com/documentation/swiftui/font/3084273-smallcaps

I've tried different ways, here are two of them:

Text("Typography")
    .font(.system(size: 24))
    .fontWeight(.bold)
    .smallCaps()

-

 Text("Typography")
     .font(.system(.body, textStyle: .smallCaps))

How can I set my letters to small caps? I’m using Xcode 11.3.

Thank you!


Solution

  • That code finally worked for me:

    Text("Typography")
        .font(Font.system(.body).smallCaps())