module Teacup::StylesheetExtension
Public Instance Methods
app_size()
click to toggle source
returns the application frame, which takes the status bar into account
# File lib/teacup-ios/stylesheet_extensions/device.rb, line 47 def app_size UIScreen.mainScreen.applicationFrame.size end
autoresize(&block)
click to toggle source
# File lib/teacup-ios/stylesheet_extensions/autoresize.rb, line 12 def autoresize &block @@autoresize ||= Autoresize.new if block return @@autoresize.instance_exec &block else return @@autoresize end end
constrain(target, attribute=nil)
click to toggle source
# File lib/teacup/stylesheet_extensions/constraints.rb, line 4 def constrain(target, attribute=nil) if attribute.nil? attribute = target target = :self end Teacup::Constraint.new(target, attribute) end
constrain_above(relative_to, margin=0)
click to toggle source
# File lib/teacup/stylesheet_extensions/constraints.rb, line 77 def constrain_above(relative_to, margin=0) margin = 8 if margin == :auto Teacup::Constraint.new(:self, :bottom).equals(relative_to, :top).minus(margin) end
constrain_below(relative_to, margin=0)
click to toggle source
|
# File lib/teacup/stylesheet_extensions/constraints.rb, line 72 def constrain_below(relative_to, margin=0) margin = 8 if margin == :auto Teacup::Constraint.new(:self, :top).equals(relative_to, :bottom).plus(margin) end
constrain_bottom(y)
click to toggle source
# File lib/teacup/stylesheet_extensions/constraints.rb, line 36 def constrain_bottom(y) Teacup::Constraint.new(:self, :bottom).equals(:superview, :bottom).plus(y) end
constrain_center_x(x=0)
click to toggle source
# File lib/teacup/stylesheet_extensions/constraints.rb, line 28 def constrain_center_x(x=0) Teacup::Constraint.new(:self, :center_x).equals(:superview, :center_x).plus(x) end
constrain_center_y(y=0)
click to toggle source
# File lib/teacup/stylesheet_extensions/constraints.rb, line 40 def constrain_center_y(y=0) Teacup::Constraint.new(:self, :center_y).equals(:superview, :center_y).plus(y) end
constrain_height(height)
click to toggle source
# File lib/teacup/stylesheet_extensions/constraints.rb, line 48 def constrain_height(height) Teacup::Constraint.new(:self, :height).equals(height) end
constrain_left(x)
click to toggle source
# File lib/teacup/stylesheet_extensions/constraints.rb, line 20 def constrain_left(x) Teacup::Constraint.new(:self, :left).equals(:superview, :left).plus(x) end
constrain_right(x)
click to toggle source
# File lib/teacup/stylesheet_extensions/constraints.rb, line 24 def constrain_right(x) Teacup::Constraint.new(:self, :right).equals(:superview, :right).plus(x) end
constrain_size(width, height)
click to toggle source
# File lib/teacup/stylesheet_extensions/constraints.rb, line 52 def constrain_size(width, height) if width.is_a? Numeric width_attr = nil else width_attr = :width end if height.is_a? Numeric height_attr = nil else height_attr = :height end [ Teacup::Constraint.new(:self, :width).equals(width, width_attr), Teacup::Constraint.new(:self, :height).equals(height, height_attr), ] end
constrain_to_left(relative_to, margin=0)
click to toggle source
# File lib/teacup/stylesheet_extensions/constraints.rb, line 87 def constrain_to_left(relative_to, margin=0) margin = 20 if margin == :auto Teacup::Constraint.new(:self, :right).equals(relative_to, :left).minus(margin) end
constrain_to_right(relative_to, margin=0)
click to toggle source
# File lib/teacup/stylesheet_extensions/constraints.rb, line 82 def constrain_to_right(relative_to, margin=0) margin = 20 if margin == :auto Teacup::Constraint.new(:self, :left).equals(relative_to, :right).plus(margin) end
constrain_top(y)
click to toggle source
# File lib/teacup/stylesheet_extensions/constraints.rb, line 32 def constrain_top(y) Teacup::Constraint.new(:self, :top).equals(:superview, :top).plus(y) end
constrain_width(width)
click to toggle source
# File lib/teacup/stylesheet_extensions/constraints.rb, line 44 def constrain_width(width) Teacup::Constraint.new(:self, :width).equals(width) end
constrain_xy(x, y)
click to toggle source
|
# File lib/teacup/stylesheet_extensions/constraints.rb, line 13 def constrain_xy(x, y) [ Teacup::Constraint.new(:self, :left).equals(:superview, :left).plus(x), Teacup::Constraint.new(:self, :top).equals(:superview, :top).plus(y), ] end
device()
click to toggle source
returns a bit-wise OR of the device masks
# File lib/teacup-ios/stylesheet_extensions/device.rb, line 52 def device @@this_device ||= nil return @@this_device if @@this_device @@this_device = 0 if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone @@this_device |= iPhone if UIScreen.mainScreen.respond_to?(:scale) && UIScreen.mainScreen.scale == 2 @@this_device |= iPhoneRetina end if UIScreen.mainScreen.bounds.size.height == 568 @@this_device |= iPhone4 else @@this_device |= iPhone35 end else @@this_device |= iPad if UIScreen.mainScreen.respond_to? :scale @@this_device |= iPadRetina end end return @@this_device end
device_is?(this_device)
click to toggle source
# File lib/teacup-ios/stylesheet_extensions/device.rb, line 79 def device_is?(this_device) this_device = self.send(this_device) if this_device.is_a? Symbol return self.device & this_device > 0 end
flexible_bottom()
click to toggle source
# File lib/teacup-ios/stylesheet_extensions/autoresize.rb, line 50 def flexible_bottom NSLog("The Stylesheet method `flexible_bottom` is deprecated, use `autoresize.flexible_bottom` instead") UIViewAutoresizingFlexibleBottomMargin end
flexible_height()
click to toggle source
# File lib/teacup-ios/stylesheet_extensions/autoresize.rb, line 45 def flexible_height NSLog("The Stylesheet method `flexible_height` is deprecated, use `autoresize.flexible_height` instead") UIViewAutoresizingFlexibleHeight end
flexible_left()
click to toggle source
| | DEPRECATED |
# File lib/teacup-ios/stylesheet_extensions/autoresize.rb, line 25 def flexible_left NSLog("The Stylesheet method `flexible_left` is deprecated, use `autoresize.flexible_left` instead") UIViewAutoresizingFlexibleLeftMargin end
flexible_right()
click to toggle source
# File lib/teacup-ios/stylesheet_extensions/autoresize.rb, line 35 def flexible_right NSLog("The Stylesheet method `flexible_right` is deprecated, use `autoresize.flexible_right` instead") UIViewAutoresizingFlexibleRightMargin end
flexible_top()
click to toggle source
# File lib/teacup-ios/stylesheet_extensions/autoresize.rb, line 40 def flexible_top NSLog("The Stylesheet method `flexible_top` is deprecated, use `autoresize.flexible_top` instead") UIViewAutoresizingFlexibleTopMargin end
flexible_width()
click to toggle source
# File lib/teacup-ios/stylesheet_extensions/autoresize.rb, line 30 def flexible_width NSLog("The Stylesheet method `flexible_width` is deprecated, use `autoresize.flexible_width` instead") UIViewAutoresizingFlexibleWidth end
flip(matrix, angle)
click to toggle source
# File lib/teacup/stylesheet_extensions/transform.rb, line 22 def flip(matrix, angle) NSLog("The Stylesheet method `flip` is deprecated, use `transform_layer.flip` instead") transform_layer.flip(angle) end
iPad()
click to toggle source
# File lib/teacup-ios/stylesheet_extensions/device.rb, line 33 def iPad ; 1 << 5 ; end
iPadRetina()
click to toggle source
# File lib/teacup-ios/stylesheet_extensions/device.rb, line 34 def iPadRetina ; 1 << 6 ; end
iPhone()
click to toggle source
# File lib/teacup-ios/stylesheet_extensions/device.rb, line 29 def iPhone ; 1 << 1 ; end
iPhone35()
click to toggle source
# File lib/teacup-ios/stylesheet_extensions/device.rb, line 32 def iPhone35 ; 1 << 4 ; end
iPhone4()
click to toggle source
# File lib/teacup-ios/stylesheet_extensions/device.rb, line 31 def iPhone4 ; 1 << 3 ; end
iPhone5()
click to toggle source
# File lib/teacup-ios/stylesheet_extensions/device.rb, line 36 def iPhone5 NSLog('TEACUP WARNING: iPhone5 method is deprecated in lieu of size-based method names (iPhone4, iPhone35)') 1 << 3 end
iPhoneRetina()
click to toggle source
# File lib/teacup-ios/stylesheet_extensions/device.rb, line 30 def iPhoneRetina ; 1 << 2 ; end
identity()
click to toggle source
# File lib/teacup/stylesheet_extensions/transform.rb, line 17 def identity NSLog("The Stylesheet method `identity` is deprecated, use `transform_layer.identity` instead") transform_layer.identity end
pi()
click to toggle source
# File lib/teacup/stylesheet_extensions/transform.rb, line 5 def pi Math::PI end
rotate(matrix, angle, x, y, z)
click to toggle source
# File lib/teacup/stylesheet_extensions/transform.rb, line 37 def rotate(matrix, angle, x, y, z) NSLog("The Stylesheet method `rotate` is deprecated, use `transform_layer.rotate` instead") transform_layer.rotate(angle, x, y, z) end
screen_size()
click to toggle source
returns the device size in points, regardless of status bar
# File lib/teacup-ios/stylesheet_extensions/device.rb, line 42 def screen_size UIScreen.mainScreen.bounds.size end
spin(matrix, angle)
click to toggle source
# File lib/teacup/stylesheet_extensions/transform.rb, line 32 def spin(matrix, angle) NSLog("The Stylesheet method `spin` is deprecated, use `transform_layer.spin` instead") transform_layer.spin(angle) end
transform_layer()
click to toggle source
# File lib/teacup/stylesheet_extensions/transform.rb, line 13 def transform_layer @@transform_layer ||= TransformLayer.new end
transform_view()
click to toggle source
# File lib/teacup/stylesheet_extensions/transform.rb, line 9 def transform_view @@transform_layer ||= TransformView.new end
twist(matrix, angle)
click to toggle source
# File lib/teacup/stylesheet_extensions/transform.rb, line 27 def twist(matrix, angle) NSLog("The Stylesheet method `twist` is deprecated, use `transform_layer.twist` instead") transform_layer.twist(angle) end