UIScreen.swift 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // UIScreen.swift
  3. // TSLiveWallpaper
  4. //
  5. // Created by 100Years on 2024/12/23.
  6. //
  7. public extension UIScreen {
  8. public static var _scale: CGFloat {
  9. if #available(iOS 13.0, *), Thread.isMainThread,
  10. let scale = UIApplication._keyWindow?.windowScene?.screen.scale {
  11. return scale
  12. }
  13. return main.scale
  14. }
  15. public static var _width: CGFloat {
  16. if #available(iOS 13.0, *), Thread.isMainThread,
  17. let width = UIApplication._keyWindow?.windowScene?.screen.bounds.width {
  18. return width
  19. }
  20. return main.bounds.width
  21. }
  22. public static var _height: CGFloat {
  23. if #available(iOS 13.0, *), Thread.isMainThread,
  24. let height = UIApplication._keyWindow?.windowScene?.screen.bounds.height {
  25. return height
  26. }
  27. return main.bounds.height
  28. }
  29. public static var _size: CGSize {
  30. if #available(iOS 13.0, *), Thread.isMainThread,
  31. let size = UIApplication._keyWindow?.windowScene?.screen.bounds.size {
  32. return size
  33. }
  34. return main.bounds.size
  35. }
  36. }