How do I use VMaskTextField with Swift?

1

How do I use VMaskTextField with Swift?

self.comVM.mask="### (##) ##"

    
asked by anonymous 09.01.2015 / 20:08

1 answer

2

Example:

class ViewController: UIViewController, UITextFieldDelegate {

    @IBOutlet weak var comVM: VMaskTextField!

    override func viewDidLoad() {
        super.viewDidLoad()

        comVM.mask = "(##) ####-####";
        comVM.delegate = self;
    }

    func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
        return comVM.shouldChangeCharactersInRange(range, replacementString: string);
    }
}

Do not forget to change the class from UITextField to VMaskTextField on storyboard / nib.

    
09.01.2015 / 20:19