修复默写输入框分隔线 crash,改用 HairlineView
This commit is contained in:
@@ -5,7 +5,7 @@ final class DictationInputView: UIView, UITextFieldDelegate {
|
|||||||
var onSubmit: (() -> Void)?
|
var onSubmit: (() -> Void)?
|
||||||
|
|
||||||
private let textField = UITextField()
|
private let textField = UITextField()
|
||||||
private let bottomLine = UIView()
|
private let bottomLine = HairlineView()
|
||||||
|
|
||||||
var text: String { textField.text?.trimmingCharacters(in: .whitespaces) ?? "" }
|
var text: String { textField.text?.trimmingCharacters(in: .whitespaces) ?? "" }
|
||||||
var isEmpty: Bool { text.isEmpty }
|
var isEmpty: Bool { text.isEmpty }
|
||||||
@@ -24,7 +24,6 @@ final class DictationInputView: UIView, UITextFieldDelegate {
|
|||||||
textField.returnKeyType = .done
|
textField.returnKeyType = .done
|
||||||
textField.addTarget(self, action: #selector(textChanged), for: .editingChanged)
|
textField.addTarget(self, action: #selector(textChanged), for: .editingChanged)
|
||||||
|
|
||||||
bottomLine.backgroundColor = .separator
|
|
||||||
bottomLine.translatesAutoresizingMaskIntoConstraints = false
|
bottomLine.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
|
||||||
addSubview(textField)
|
addSubview(textField)
|
||||||
@@ -42,7 +41,6 @@ final class DictationInputView: UIView, UITextFieldDelegate {
|
|||||||
bottomLine.leadingAnchor.constraint(equalTo: textField.leadingAnchor),
|
bottomLine.leadingAnchor.constraint(equalTo: textField.leadingAnchor),
|
||||||
bottomLine.trailingAnchor.constraint(equalTo: textField.trailingAnchor),
|
bottomLine.trailingAnchor.constraint(equalTo: textField.trailingAnchor),
|
||||||
bottomLine.bottomAnchor.constraint(equalTo: textField.bottomAnchor),
|
bottomLine.bottomAnchor.constraint(equalTo: textField.bottomAnchor),
|
||||||
bottomLine.heightAnchor.constraint(equalToConstant: 1.0 / UITraitCollection().displayScale),
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user