Skip to content

Instantly share code, notes, and snippets.

@darsen
Created August 6, 2015 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darsen/c193d5803bac146fa1ff to your computer and use it in GitHub Desktop.
Save darsen/c193d5803bac146fa1ff to your computer and use it in GitHub Desktop.
Custom TextField in swift
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