Revision control

Copy as Markdown

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import UIKit
class InsetTextField: UITextField {
private let insetBy: CGFloat
init(insetBy: CGFloat) {
self.insetBy = insetBy
super.init(frame: .zero)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init?(coder:) not implemented!")
}
override func textRect(forBounds bounds: CGRect) -> CGRect {
return bounds.insetBy(dx: insetBy, dy: insetBy)
}
override func editingRect(forBounds bounds: CGRect) -> CGRect {
return bounds.insetBy(dx: insetBy, dy: insetBy)
}
}