Created
August 6, 2015 16:07
-
-
Save darsen/c193d5803bac146fa1ff to your computer and use it in GitHub Desktop.
Custom TextField in swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
class CustomTextField: UITextField, UITextFieldDelegate{ | |
required init(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
self.delegate = self | |
} | |
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool { | |
if (string == "X" ){ | |
//ignore input | |
return false | |
} | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment