summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2021-10-08 13:38:37 +0200
committerAndrej Mihajlov <and@mullvad.net>2021-11-03 13:30:51 +0100
commit8e24d1b1c03f1b6e8ffef80771b7d9f7da95fda1 (patch)
treec368888229cae8222348c6636531b67689e62bd7
parent8856fa426214f41cc8454e56b1cd64ce0530c901 (diff)
downloadmullvadvpn-8e24d1b1c03f1b6e8ffef80771b7d9f7da95fda1.tar.xz
mullvadvpn-8e24d1b1c03f1b6e8ffef80771b7d9f7da95fda1.zip
CustomTextField: make corner radius and text margins customizable
-rw-r--r--ios/MullvadVPN/CustomTextField.swift18
1 files changed, 14 insertions, 4 deletions
diff --git a/ios/MullvadVPN/CustomTextField.swift b/ios/MullvadVPN/CustomTextField.swift
index 378dde07aa..c923d3e925 100644
--- a/ios/MullvadVPN/CustomTextField.swift
+++ b/ios/MullvadVPN/CustomTextField.swift
@@ -9,10 +9,20 @@
import Foundation
import UIKit
-private let kTextFieldCornerRadius = CGFloat(4)
-
class CustomTextField: UITextField {
+ var cornerRadius: CGFloat = 4 {
+ didSet {
+ layer.cornerRadius = cornerRadius
+ }
+ }
+
+ var textMargins = UIEdgeInsets(top: 12, left: 14, bottom: 12, right: 14) {
+ didSet {
+ setNeedsLayout()
+ }
+ }
+
var placeholderTextColor: UIColor = UIColor.TextField.placeholderTextColor {
didSet {
updatePlaceholderTextColor()
@@ -29,7 +39,7 @@ class CustomTextField: UITextField {
super.init(frame: frame)
textColor = UIColor.TextField.textColor
- layer.cornerRadius = kTextFieldCornerRadius
+ layer.cornerRadius = cornerRadius
clipsToBounds = true
}
@@ -48,7 +58,7 @@ class CustomTextField: UITextField {
}
override func textRect(forBounds bounds: CGRect) -> CGRect {
- return bounds.insetBy(dx: 14, dy: 12)
+ return bounds.inset(by: textMargins)
}
override func editingRect(forBounds bounds: CGRect) -> CGRect {