Created
February 5, 2023 20:08
-
-
Save foxicode/c03e7e46007c367bb7b1884ef94bd459 to your computer and use it in GitHub Desktop.
Underlined text field component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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