Manos Chorianopoulos

add done button at keyboard at shareVC

...@@ -78,6 +78,7 @@ import SwiftEventBus ...@@ -78,6 +78,7 @@ import SwiftEventBus
78 numberTextField.textColor = UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00) 78 numberTextField.textColor = UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00)
79 numberTextField.attributedPlaceholder = NSAttributedString(string: "Καταχώρηση τηλεφώνου", attributes: [NSAttributedString.Key.foregroundColor: UIColor(red: 0.68, green: 0.68, blue: 0.68, alpha: 1.00)]) 79 numberTextField.attributedPlaceholder = NSAttributedString(string: "Καταχώρηση τηλεφώνου", attributes: [NSAttributedString.Key.foregroundColor: UIColor(red: 0.68, green: 0.68, blue: 0.68, alpha: 1.00)])
80 numberTextField.keyboardType = .asciiCapableNumberPad 80 numberTextField.keyboardType = .asciiCapableNumberPad
81 + numberTextField.addDoneButtonOnKeyboard()
81 82
82 redeemButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16) 83 redeemButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16)
83 redeemButton.setTitle("Αποστολή με SMS", for: .normal) 84 redeemButton.setTitle("Αποστολή με SMS", for: .normal)
......
...@@ -299,3 +299,36 @@ public extension CGPoint { ...@@ -299,3 +299,36 @@ public extension CGPoint {
299 } 299 }
300 } 300 }
301 } 301 }
302 +
303 +extension UITextField {
304 + @IBInspectable var doneAccessory: Bool{
305 + get{
306 + return self.doneAccessory
307 + }
308 + set (hasDone) {
309 + if hasDone{
310 + addDoneButtonOnKeyboard()
311 + }
312 + }
313 + }
314 +
315 + func addDoneButtonOnKeyboard()
316 + {
317 + let doneToolbar: UIToolbar = UIToolbar(frame: CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 50))
318 + doneToolbar.barStyle = .default
319 +
320 + let flexSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
321 + let done: UIBarButtonItem = UIBarButtonItem(title: "Done", style: .done, target: self, action: #selector(self.doneButtonAction))
322 +
323 + let items = [flexSpace, done]
324 + doneToolbar.items = items
325 + doneToolbar.sizeToFit()
326 +
327 + self.inputAccessoryView = doneToolbar
328 + }
329 +
330 + @objc func doneButtonAction()
331 + {
332 + self.resignFirstResponder()
333 + }
334 +}
......