Updated for Xcode 12.0
New in iOS 14
SwiftUI’s TextField
view normally lets users write their text in whatever case they want, but if you want to control that you can force either uppercase or lowercase text using the textCase()
modifier.
For example, this asks users to enter their name and uppercases every letter:
struct ContentView: View {
@State private var name = "Paul"
var body: some View {
TextField("Shout your name at me", text: $name)
.textFieldStyle(RoundedBorderTextFieldStyle())
.textCase(.uppercase)
.padding(.horizontal)
}
}
SPONSORED From January 26th to 31st you can join a FREE crash course for iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a senior developer!
Sponsor Hacking with Swift and reach the world's largest Swift community!
Link copied to your pasteboard.