UIScreen+YYAdd.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // UIScreen+YYAdd.h
  3. // YYKit <https://github.com/ibireme/YYKit>
  4. //
  5. // Created by ibireme on 13/4/5.
  6. // Copyright (c) 2015 ibireme.
  7. //
  8. // This source code is licensed under the MIT-style license found in the
  9. // LICENSE file in the root directory of this source tree.
  10. //
  11. #import <UIKit/UIKit.h>
  12. NS_ASSUME_NONNULL_BEGIN
  13. /**
  14. Provides extensions for `UIScreen`.
  15. */
  16. @interface UIScreen (YYAdd)
  17. /**
  18. Main screen's scale
  19. @return screen's scale
  20. */
  21. + (CGFloat)screenScale;
  22. /**
  23. Returns the bounds of the screen for the current device orientation.
  24. @return A rect indicating the bounds of the screen.
  25. @see boundsForOrientation:
  26. */
  27. - (CGRect)currentBounds NS_EXTENSION_UNAVAILABLE_IOS("");
  28. /**
  29. Returns the bounds of the screen for a given device orientation.
  30. `UIScreen`'s `bounds` method always returns the bounds of the
  31. screen of it in the portrait orientation.
  32. @param orientation The orientation to get the screen's bounds.
  33. @return A rect indicating the bounds of the screen.
  34. @see currentBounds
  35. */
  36. - (CGRect)boundsForOrientation:(UIInterfaceOrientation)orientation;
  37. /**
  38. The screen's real size in pixel (width is always smaller than height).
  39. This value may not be very accurate in an unknown device, or simulator.
  40. e.g. (768,1024)
  41. */
  42. @property (nonatomic, readonly) CGSize sizeInPixel;
  43. /**
  44. The screen's PPI.
  45. This value may not be very accurate in an unknown device, or simulator.
  46. Default value is 96.
  47. */
  48. @property (nonatomic, readonly) CGFloat pixelsPerInch;
  49. @end
  50. NS_ASSUME_NONNULL_END