how to use persian numbers in UItextField in swift 3?

前端 未结 1 737
一向
一向 2021-01-26 12:08

Hi I am using text field in my swift3 application - I want when user enter a number in the text field instead of english number textfield shows persian numbers - my textfield ke

相关标签:
1条回答
  • 2021-01-26 13:03

    try this :

     func convertEngNumToPersianNum(num: String)->String{
            let number = NSNumber(value: Int(num)!)
            let format = NumberFormatter()
            format.locale = Locale(identifier: "fa_IR")
            let faNumber = format.string(from: number)
    
            return faNumber!
        }
    
    0 讨论(0)
提交回复
热议问题