Guest User

Untitled

a guest
Oct 16th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 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. background_color = 0x000000
  27. background_image = "default_background.png"
  28. background_size = :cover
  29.  
  30. # Set "label.png" as background image only if it's an UITextField-Element
  31. context UITextfield do |c|
  32. c.background_image = "textfield.png"
  33. end
  34.  
  35.  
  36. # Set "label.png" as background image only
  37. # if it's an UILabel-Element and device orientation is landscape
  38. context UILabel, :landscape do |c|
  39. c.background_image = "label_landscape.png"
  40. end
  41.  
  42. # Set "label.png" as background image only
  43. # if it's an UILabel-Element and device orientation is portrait
  44. context UILabel, :portrait do |c|
  45. c.background_image = "label_portrait.png"
  46. end
  47.  
  48. end
  49.  
  50. end
  51.  
  52. # /app/stylesheets/application.pad.rb
  53. # Additional outfit for iPad devices
  54. class Application < Stylesheets::Pad
  55.  
  56. outfit :awesome_default do
  57. width = 400
  58. height = 300
  59. end
  60.  
  61. end
  62.  
  63. # /app/stylesheets/application.phone.rb
  64. # Additional outfit for iPhone and iPod touch devices
  65. class Application < Stylesheets::Phone
  66.  
  67. outfit :awesome_default do
  68. width = 200
  69. height = 100
  70. end
  71.  
  72. end
  73.  
  74.  
  75. # /app/somewhere_else.rb
  76.  
  77. @calculate_button = button.named("calculate").outfit(:awesome_default)
  78.  
  79. @calculate_button.on(:touch) do |b|
  80. calculate
  81. end
  82.  
  83. @calculate_button.on(:swipe_left) do |b|
  84. calculate_with_awesome_effect
  85. end
Add Comment
Please, Sign In to add comment