updated TextField
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
c44beb5e32
commit
cee2209dc6
@ -11,6 +11,7 @@ import VDS
|
|||||||
import VDSFormControlsTokens
|
import VDSFormControlsTokens
|
||||||
|
|
||||||
public class TextField: UITextField {
|
public class TextField: UITextField {
|
||||||
|
|
||||||
public var isNumeric: Bool = false
|
public var isNumeric: Bool = false
|
||||||
|
|
||||||
public var textPadding = UIEdgeInsets(
|
public var textPadding = UIEdgeInsets(
|
||||||
@ -23,12 +24,29 @@ public class TextField: UITextField {
|
|||||||
public override init(frame: CGRect) {
|
public override init(frame: CGRect) {
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
font = TextStyle.bodyLarge.font
|
font = TextStyle.bodyLarge.font
|
||||||
|
setup()
|
||||||
}
|
}
|
||||||
|
|
||||||
public required init?(coder: NSCoder) {
|
public required init?(coder: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func setup() {
|
||||||
|
let keypadToolbar: UIToolbar = UIToolbar()
|
||||||
|
|
||||||
|
// add a done button to the numberpad
|
||||||
|
keypadToolbar.items=[
|
||||||
|
UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: self, action: nil),
|
||||||
|
UIBarButtonItem(title: "Done", style: UIBarButtonItem.Style.done, target: self, action: #selector(UITextField.resignFirstResponder))
|
||||||
|
]
|
||||||
|
keypadToolbar.sizeToFit()
|
||||||
|
|
||||||
|
// add a toolbar with a done button above the number pad
|
||||||
|
inputAccessoryView = keypadToolbar
|
||||||
|
keyboardType = .alphabet
|
||||||
|
returnKeyType = .done
|
||||||
|
}
|
||||||
|
|
||||||
public override func textRect(forBounds bounds: CGRect) -> CGRect {
|
public override func textRect(forBounds bounds: CGRect) -> CGRect {
|
||||||
layer.borderColor = UIColor.black.cgColor
|
layer.borderColor = UIColor.black.cgColor
|
||||||
layer.borderWidth = VDSFormControls.widthBorder
|
layer.borderWidth = VDSFormControls.widthBorder
|
||||||
@ -53,4 +71,9 @@ public class NumericField: TextField {
|
|||||||
public required init?(coder: NSCoder) {
|
public required init?(coder: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override func setup() {
|
||||||
|
super.setup()
|
||||||
|
keyboardType = .numberPad
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user