Last active
October 19, 2022 21:46
-
-
Save sindresorhus/e304f157e1fc2b4e63dedc151b25b583 to your computer and use it in GitHub Desktop.
iOS 16 deprecated `UIScreen#screens`. Here's how to silence the deprecation until you can move to the new API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private protocol SilenceDeprecationForUIScreenWindows { | |
var screens: [UIScreen] { get } | |
} | |
private final class SilenceDeprecationForUIScreenWindowsImplementation: SilenceDeprecationForUIScreenWindows { | |
@available(iOS, deprecated: 16) | |
var screens: [UIScreen] { UIScreen.screens } | |
} | |
extension UIScreen { | |
static var screens2: [UIScreen] { | |
(SilenceDeprecationForUIScreenWindowsImplementation() as SilenceDeprecationForUIScreenWindows).screens | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment