]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
UI: iOS: Fix placeholder label alignment in text fields.
authorAndrej Mihajlov <and@mullvad.net>
Wed, 23 Dec 2020 15:03:01 +0000 (16:03 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 23 Dec 2020 15:14:03 +0000 (16:14 +0100)
Signed-off-by: Andrej Mihajlov <and@mullvad.net>
Sources/WireGuardApp/UI/iOS/View/KeyValueCell.swift

index f99e3eac963c7802280185ddcedf3dca383bb573..70b97c8a8e3dbb16fbf3228da1119517abcf51f3 100644 (file)
@@ -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)
+    }
+}