From 1e17f6d8df39251a9fdc124bb0fade98f69b41d8 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz <42140194+IsaacMarovitz@users.noreply.github.com> Date: Wed, 18 Jan 2023 23:49:02 -0500 Subject: [PATCH] Fix macOS 13.2 Display Issue (#66) * Attempt 1 * Fix * style: variable names represent their values * #available * Fix `if #available` Co-authored-by: TheMoonThatRises <58153205+TheMoonThatRises@users.noreply.github.com> --- PlayTools/PlayScreen.swift | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/PlayTools/PlayScreen.swift b/PlayTools/PlayScreen.swift index b933df85..6648aa96 100644 --- a/PlayTools/PlayScreen.swift +++ b/PlayTools/PlayScreen.swift @@ -20,7 +20,11 @@ extension CGSize { } func toAspectRatio() -> CGSize { - return CGSize(width: mainScreenHeight, height: mainScreenWidth) + if #available(macCatalyst 16.3, *) { + return CGSize(width: mainScreenWidth, height: mainScreenHeight) + } else { + return CGSize(width: mainScreenHeight, height: mainScreenWidth) + } } } @@ -34,11 +38,11 @@ extension CGRect { } func toAspectRatio() -> CGRect { - return CGRect(x: minX, y: minY, width: mainScreenHeight, height: mainScreenWidth) + return CGRect(x: minX, y: minY, width: mainScreenWidth, height: mainScreenHeight) } func toAspectRatioReversed() -> CGRect { - return CGRect(x: minX, y: minY, width: mainScreenWidth, height: mainScreenHeight) + return CGRect(x: minX, y: minY, width: mainScreenHeight, height: mainScreenWidth) } } @@ -65,11 +69,11 @@ public class PlayScreen: NSObject { @objc public static let shared = PlayScreen() @objc public static func frame(_ rect: CGRect) -> CGRect { - return rect.toAspectRatio() + return rect.toAspectRatioReversed() } @objc public static func bounds(_ rect: CGRect) -> CGRect { - return rect.toAspectRatioReversed() + return rect.toAspectRatio() } @objc public static func width(_ size: Int) -> Int {