how do I change textField keyboard to be Arabic numbers only? Swift / UIKit

Viewed 636

I'm trying to make my text field show only Arabic numbers keyboard, no matter what language the device have. I changed the app base language to Arabic and it is still showing me English numbers.

keyboardImage

1 Answers

You can create a subclass like ArabicTextField of UITextField and use textInputMode property to change your keyboard as below

class ArabicTextField: UITextField {
    override var textInputMode: UITextInputMode? {
        UITextInputMode.activeInputModes.filter
        { $0.primaryLanguage == "ar" }.first ?? super.textInputMode } 
}
Related