UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Is it possible to change language of keyboard layout in SwiftUI?

Forums > SwiftUI

I can't find anything on changing keyboard language layout in SwiftUI when entering text in a TextField, as I've been able to do for regular Swift.

3      

Not sure what you mean but if .keyboardType() modifier and you get a number of option see UIKeyboardType

TextField("", text: $text)
    .keyboardType(.emailAddress)

3      

@NigelGee No, I don't mean that. I want to change keyboard language layout based on a BCP code I get from querying the system for the language locale the device is set to. I have achieved this in UIKit, but don't see an officially supported equivalent in SwiftUI.

3      

But shouldn't the app always use the keyboard language the user has set it to?

3      

@Hatsushira It's a language learning app, the user has the option of typing in foreign words using a foreignor native keyboard. A toggle switch allows the keyboard layout to switch between a native or foreign keyboard layout!

3      

Ah, okay, now it makes sense for me. My guess is that you have to rely on the UIKit API because I haven't found anything on SwiftUI.

3      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.