NEW: Learn to build amazing SwiftUI apps for macOS with my new book! >>

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.


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

TextField("", text: $text)


@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.


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


@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!


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.


Hacking with Swift is sponsored by RevenueCat

SPONSORED Spend less time managing in-app purchase infrastructure so you can focus on building your app. RevenueCat gives everything you need to easily implement, manage, and analyze in-app purchases and subscriptions without managing servers or writing backend code.

Get Started

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

Reply to this topic…

You need to create an account or log in to reply.

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.