summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2020-07-15 17:17:06 +0200
committerAndrej Mihajlov <and@mullvad.net>2020-07-15 18:12:28 +0200
commit69ce8dd0a2b621f8466e79f612a1e87a56c2aaf3 (patch)
treeec011776064b8ad1d6d66c416e3b8faa64becddc
parent06635b3c9071219ef260b9666cf7d20a82d754d6 (diff)
downloadmullvadvpn-69ce8dd0a2b621f8466e79f612a1e87a56c2aaf3.tar.xz
mullvadvpn-69ce8dd0a2b621f8466e79f612a1e87a56c2aaf3.zip
Fix layout quirks in UIButton on iOS < 13
-rw-r--r--ios/MullvadVPN/AppButton.swift15
1 files changed, 15 insertions, 0 deletions
diff --git a/ios/MullvadVPN/AppButton.swift b/ios/MullvadVPN/AppButton.swift
index b98cc9c2cc..25eed30cf8 100644
--- a/ios/MullvadVPN/AppButton.swift
+++ b/ios/MullvadVPN/AppButton.swift
@@ -212,6 +212,21 @@ private extension UIControl.State {
}
}
+ override func layoutSubviews() {
+ super.layoutSubviews()
+
+ if #available(iOS 13, *) {
+ // no-op
+ } else {
+ // Fix: on iOS 12 the image view frame is not always set, even though the `UIButton`
+ // calls `imageRect` to compute the image layout frame.
+ let imageRect = self.imageRect(forContentRect: contentRect(forBounds: bounds))
+ if imageView?.frame != imageRect {
+ imageView?.frame = imageRect
+ }
+ }
+ }
+
private func computeLayout(forContentRect contentRect: CGRect) -> (CGRect, CGRect) {
var imageRect = super.imageRect(forContentRect: contentRect)
var titleRect = super.titleRect(forContentRect: contentRect)