SHARE
TWEET

Untitled

a guest Jun 18th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  UITextField.swift
  3. //  MasjidLink
  4. //
  5. //  Created by Sebastian Vidrea on 07/06/2019.
  6. //  Copyright © 2019 Sebastian Vidrea. All rights reserved.
  7. //
  8.  
  9. import Foundation
  10. import UIKit
  11.  
  12. extension UITextField {
  13.  
  14.     class func connectFields(fields: [UITextField]) -> Void {
  15.         guard let last = fields.last else {
  16.             return
  17.         }
  18.        
  19.         for index in 0 ..< fields.count - 1 {
  20.             fields[index].returnKeyType = .next
  21.             fields[index].addTarget(fields[index + 1],
  22.                                     action: #selector(UIResponder.becomeFirstResponder),
  23.                                     for: .editingDidEndOnExit)
  24.         }
  25.        
  26.         last.returnKeyType = .done
  27.         last.addTarget(last, action: #selector(UIResponder.resignFirstResponder),
  28.                        for: .editingDidEndOnExit)
  29.     }
  30.  
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top