Module: BubbleWrap::Device::Screen
- Defined in:
- motion/core/device/screen.rb
Class Method Summary (collapse)
-
+ (Object) height
The height of the device's screen.
-
+ (Object) height_for_orientation(o = orientation)
The same as `.width` and `.height` but compensating for screen rotation (which can do your head in).
-
+ (:portrait, ...) orientation(device_orientation = UIDevice.currentDevice.orientation)
Figure out the current physical orientation of the device.
-
+ (TrueClass, FalseClass) retina?(screen = UIScreen.mainScreen)
Certifies that the device running the app has a Retina display.
-
+ (Object) width
The width of the device's screen.
-
+ (Object) width_for_orientation(o = orientation)
The same as `.width` and `.height` but compensating for screen rotation (which can do your head in).
Class Method Details
+ (Object) height
The height of the device's screen. The real resolution is dependant on the scale factor (see `retina?`) but the coordinate system is in non-retina pixels. You can get pixel accuracy by using half-coordinates. This is a Float
48 49 50 |
# File 'motion/core/device/screen.rb', line 48 def height UIScreen.mainScreen.bounds.size.height end |
+ (Object) height_for_orientation(o = orientation)
The same as `.width` and `.height` but compensating for screen rotation (which can do your head in).
63 64 65 66 |
# File 'motion/core/device/screen.rb', line 63 def height_for_orientation(o=orientation) return width if (o == :landscape_left) || (o == :landscape_right) height end |
+ (:portrait, ...) orientation(device_orientation = UIDevice.currentDevice.orientation)
Figure out the current physical orientation of the device
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'motion/core/device/screen.rb', line 19 def orientation(device_orientation=UIDevice.currentDevice.orientation) case device_orientation when UIDeviceOrientationPortrait then :portrait when UIDeviceOrientationPortraitUpsideDown then :portrait_upside_down when UIDeviceOrientationLandscapeLeft then :landscape_left when UIDeviceOrientationLandscapeRight then :landscape_right when UIDeviceOrientationFaceUp then :face_up when UIDeviceOrientationFaceDown then :face_down else :unknown end end |
+ (TrueClass, FalseClass) retina?(screen = UIScreen.mainScreen)
Certifies that the device running the app has a Retina display
9 10 11 12 13 14 15 |
# File 'motion/core/device/screen.rb', line 9 def retina?(screen=UIScreen.mainScreen) if screen.respondsToSelector('displayLinkWithTarget:selector:') && screen.scale == 2.0 true else false end end |
+ (Object) width
The width of the device's screen. The real resolution is dependant on the scale factor (see `retina?`) but the coordinate system is in non-retina pixels. You can get pixel accuracy by using half-coordinates. This is a Float
38 39 40 |
# File 'motion/core/device/screen.rb', line 38 def width UIScreen.mainScreen.bounds.size.width end |
+ (Object) width_for_orientation(o = orientation)
The same as `.width` and `.height` but compensating for screen rotation (which can do your head in).
55 56 57 58 |
# File 'motion/core/device/screen.rb', line 55 def width_for_orientation(o=orientation) return height if (o == :landscape_left) || (o == :landscape_right) width end |