Guest User

Untitled

a guest
Oct 16th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. # Inline styles
  2. @calculate_button = UIButton.named(I18n.t(:calculate_button)).style(color: 0xFFFFFF, align: :center, vertical_align: :center, top: 10, left: 30, width: 120, height: 40)
  3.  
  4.  
  5. # External styles
  6. # /app/stylesheets/application.rb
  7. class ApplicationStylesheet < Stylesheets::Base
  8.  
  9. # Stylesheets for UI-Elements
  10. # usage: @element.outfit(:awesome_default)
  11.  
  12. outfit :description_label do
  13. color 0xFFFFFF
  14. align :center
  15. width 400
  16. height 300
  17. top 40
  18. left 60
  19. end
  20.  
  21. outfit :awesome_default do
  22. color 0xFFFFFF
  23. align :center
  24. top 40
  25. left 60
  26.  
  27. background do
  28. color 0x000000
  29. image "default_background.png"
  30. size :cover
  31. end
  32.  
  33. # or
  34. # background_color 0x000000
  35. # background_image "default_background.png"
  36. # background_size :cover
  37.  
  38. # Set "label.png" as background image only if it's an UITextField-Element
  39. context UITextfield do |c|
  40. c.background_image "textfield.png"
  41. end
  42.  
  43.  
  44. # Set "label.png" as background image only
  45. # if it's an UILabel-Element and device orientation is landscape
  46. context UILabel, :landscape do |c|
  47. c.background_image "label_landscape.png"
  48. end
  49.  
  50. # Set "label.png" as background image only
  51. # if it's an UILabel-Element and device orientation is portrait
  52. context UILabel, :portrait do |c|
  53. c.background_image "label_portrait.png"
  54. end
  55.  
  56. end
  57.  
  58. end
  59.  
  60. # /app/stylesheets/application.pad.rb
  61. # Additional outfit for iPad devices
  62. class Application < Stylesheets::Pad
  63.  
  64. outfit :awesome_default do
  65. width 400
  66. height 300
  67. end
  68.  
  69. end
  70.  
  71. # /app/stylesheets/application.phone.rb
  72. # Additional outfit for iPhone and iPod touch devices
  73. class Application < Stylesheets::Phone
  74.  
  75. outfit :awesome_default do
  76. width 200
  77. height 100
  78. end
  79.  
  80. end
  81.  
  82.  
  83. # /app/somewhere_else.rb
  84.  
  85. @calculate_button = button.named("calculate").outfit(:awesome_default)
  86.  
  87. @calculate_button.on(:press) do |b|
  88. calculate
  89. end
  90.  
  91. @calculate_button.on(:swipe_left) do |b|
  92. calculate_with_awesome_effect
  93. end
Add Comment
Please, Sign In to add comment