Skip to content

Instantly share code, notes, and snippets.

@foxicode
Created February 5, 2023 20:08
Show Gist options
  • Select an option

  • Save foxicode/c03e7e46007c367bb7b1884ef94bd459 to your computer and use it in GitHub Desktop.

Select an option

Save foxicode/c03e7e46007c367bb7b1884ef94bd459 to your computer and use it in GitHub Desktop.
Underlined text field component
import SnapKit
import UIKit
class UnderlinedTextField: UIView {
lazy var textField: UITextField = {
let textField = UITextField()
textField.backgroundColor = .clear
textField.borderStyle = .none
return textField
}()
lazy var underline = HorizontalLineView(backgroundColor: .lightGray, height: 1)
init() {
super.init(frame: .zero)
addSubview(textField) {
$0.fillHorizontally()
$0.top.equalToSuperview()
$0.bottom.equalToSuperview().offset(-1)
}
addSubview(underline) {
$0.fillHorizontally()
$0.bottom.equalToSuperview()
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment