From: Andrej Mihajlov Date: Wed, 23 Dec 2020 15:03:01 +0000 (+0100) Subject: UI: iOS: Fix placeholder label alignment in text fields. X-Git-Tag: 1.0.13-24~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=491301f58b7c6746b5c694f9c7932d6d3c138c56;p=thirdparty%2Fwireguard-apple.git UI: iOS: Fix placeholder label alignment in text fields. Signed-off-by: Andrej Mihajlov --- diff --git a/Sources/WireGuardApp/UI/iOS/View/KeyValueCell.swift b/Sources/WireGuardApp/UI/iOS/View/KeyValueCell.swift index f99e3ea..70b97c8 100644 --- a/Sources/WireGuardApp/UI/iOS/View/KeyValueCell.swift +++ b/Sources/WireGuardApp/UI/iOS/View/KeyValueCell.swift @@ -27,7 +27,7 @@ class KeyValueCell: UITableViewCell { }() let valueTextField: UITextField = { - let valueTextField = UITextField() + let valueTextField = KeyValueCellTextField() valueTextField.textAlignment = .right valueTextField.isEnabled = false valueTextField.font = UIFont.preferredFont(forTextStyle: .body) @@ -234,3 +234,10 @@ extension KeyValueCell: UITextFieldDelegate { } } + +class KeyValueCellTextField: UITextField { + override func placeholderRect(forBounds bounds: CGRect) -> CGRect { + // UIKit renders the placeholder label 0.5pt higher + return super.placeholderRect(forBounds: bounds).integral.offsetBy(dx: 0, dy: -0.5) + } +}