But later I found the solution which works for me
Swift 5
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
var finalString = ""
if range.length > 0 {
finalString = "(textField.text!.dropLast())"
} else {
finalString = "(textField.text! + string)"
}
print(finalString)
return true
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…