mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Fix placeholder of textfield
This commit is contained in:
parent
ba7b27bdc4
commit
82c62265c5
2 changed files with 21 additions and 0 deletions
|
@ -30,6 +30,7 @@ extension TextFieldTableViewCell: Themable {
|
|||
|
||||
func update(theme: Theme) {
|
||||
theme.applyStyle(onTextField: textField)
|
||||
textField.placeholderColor = theme.placeholderTextColor
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,26 @@ class InsettedTextField: UITextField {
|
|||
}
|
||||
}
|
||||
|
||||
var placeholderColor: UIColor? {
|
||||
didSet {
|
||||
updateAttributedPlaceholder()
|
||||
}
|
||||
}
|
||||
|
||||
override var placeholder: String? {
|
||||
didSet {
|
||||
updateAttributedPlaceholder()
|
||||
}
|
||||
}
|
||||
|
||||
private func updateAttributedPlaceholder() {
|
||||
guard let placeholder = placeholder else { return }
|
||||
guard let color = placeholderColor else { return }
|
||||
attributedPlaceholder = NSAttributedString(string: placeholder, attributes: [
|
||||
NSAttributedString.Key.foregroundColor: color
|
||||
])
|
||||
}
|
||||
|
||||
override func placeholderRect(forBounds bounds: CGRect) -> CGRect {
|
||||
return bounds.inset(by: insets)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue