我正在尝试使用以下代码创建信用卡类型文本,但无法做到这一点,有什么办法吗?
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
let formatter = NSNumberFormatter()
formatter.groupingSize = 4
formatter.groupingSeparator = "-"
formatter.usesGroupingSeparator = true
print("txtCardNumber \(txtCardNumber.text)")
}