mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-26 19:34:25 +02:00
Fix placeholder of textfield
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user