57 lines
1.4 KiB
Swift
57 lines
1.4 KiB
Swift
//
|
|
// TextField.swift
|
|
// VDSSample
|
|
//
|
|
// Created by Matt Bruce on 8/24/22.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
import VDS
|
|
import VDSFormControlsTokens
|
|
|
|
public class TextField: UITextField {
|
|
public var isNumeric: Bool = false
|
|
|
|
public var textPadding = UIEdgeInsets(
|
|
top: 10,
|
|
left: 10,
|
|
bottom: 10,
|
|
right: 10
|
|
)
|
|
|
|
public override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
font = TextStyle.BodyLarge.font
|
|
}
|
|
|
|
public required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
public override func textRect(forBounds bounds: CGRect) -> CGRect {
|
|
layer.borderColor = UIColor.black.cgColor
|
|
layer.borderWidth = VDSFormControls.widthBorder
|
|
let rect = super.textRect(forBounds: bounds)
|
|
return rect.inset(by: textPadding)
|
|
}
|
|
|
|
public override func editingRect(forBounds bounds: CGRect) -> CGRect {
|
|
layer.borderColor = UIColor.black.cgColor
|
|
layer.borderWidth = VDSFormControls.widthBorder
|
|
let rect = super.editingRect(forBounds: bounds)
|
|
return rect.inset(by: textPadding)
|
|
}
|
|
}
|
|
|
|
public class NumericField: TextField {
|
|
public override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
isNumeric = true
|
|
}
|
|
|
|
public required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
}
|