Use .smallCaps() in SwiftUI
Asked Answered
H

1

6

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!

Halve answered 31/3, 2020 at 22:18 Comment(0)
H
14

That code finally worked for me:

Text("Typography")
    .font(Font.system(.body).smallCaps())
Halve answered 31/3, 2020 at 22:30 Comment(1)
Slightly shorter way to write it, if you're interested: Text("Typography") .font(.body.smallCaps())Demavend

© 2022 - 2024 — McMap. All rights reserved.