now
motion-now is a DSL for working with UIViews in your rubymotion application. Now borrows all of it's good ideas from jQuery.
Installation
to install now, run:
gem install motion-now
add the following line to your rubymotion Rakefile
require 'motion-now'
Examples
Creating views
Creating a button that says 'Hi!'
button = Now.button "Say Hi!" do |button|
button.width 100
button.height 50
end.click do
Now.alert "Hi!"
end
self.view.now.add button
Moving Views Around
circle = Now.view do |view|
view.size "10x10"
view.border_radius 10
view.background_color "#f4f4f4"
end
# To center a view in its parent view
circle.center
# To align in the top-right corner of parent view
# Same as circle.top(0).right(0)
circle.top.right
Sizing Views
square = Now.view
# make the height 10px
square.height 10
# every square is the same size on all sides
square.width 10
# there's an easier way
square.size "10x10"
# or ..
square.size [10, 10]
Properties
ball = Now.image "ball.png"
# to hide ball:
ball.hide
# let's bring it back
ball.show
# let's ghostify it
ball.alpha(10)
.shadow(1, 1, 10, "blue")
.add_animation(:giggle)