SwiftUI: How to use a different Font with a TextField
As we developers create an app, we always want to put our customized touches to it. Fortunately, Xcode and SwiftUI makes it easy to bring custom fonts to your apps.
Thank you for reading this post, don't forget to subscribe!
Using a TextField allows a user to input data into the app. But wouldn’t it be nice if you could customized the look of the text field with a font that would look great? Here’s the code:
1 / Text(“What would you like to say?”)
2 / .bold()
3 / .font(.custom(“Times New Roman”, size: 30))
4 / .foregroundColor(Color.white)
5 / .multilineTextAlignment(.center)
The above is a standard text field with customization. But look at line 3. I use the standard font command with the word .custom and then the name of the font that I wish to have, and then the size of the font.
About Post Author
Discover more from CompuScoop.com
Subscribe to get the latest posts sent to your email.