FontAwesome (http://fortawesome.github.io/Font-Awesome) is a really cool way to bring in some low cost bang! to your web applications. Following on that lead, MotionAwesome brings similar awesomeness to the IOS world...
> git clone https://github.com/derailed/motion-awesome.git
> cd motion-awesome
> rake
gem install motion-awesome
If you are using Bundler in your Rubymotion, you can add the gem to your Gemfile and run bundle install
:
gem 'motion-awesome'
The FontAwesome font file will automatically be copied to your resources folder. Make sure to include the font in your Rakefile:
# ...
Motion::Project::App.setup do |app|
# ...
app.fonts = ['fontawesome-webfont.ttf']
end
- motion-map [https://github.com/derailed/motion-map]
If you are adding motion-awesome to an existing project,
you may run into a common issue with RubyMotion where the added font file
is not copied from the resources.
To fix this simply run a rake clean
and then try again.
class WannaBeCoolController < XXXController
include MotionAwesome
def viewDidLoad
label( :flag, size: 200 ) do |label|
self.view.addSubview(label)
end
end
end
class WannaBeCoolController < XXXController
def viewDidLoad
MotionAwesome.button( :legal, size: 40, text:%q{Hit me!} ) do |button|
button.titleLabel.textColor = 0xFB3223.uicolor
button.titleLabel.font = UIFont.fontWithName( 'GillSans', size:30 )
button.addTarget( self,
action: "cb:",
forControlEvents: UIControlEventTouchUpInside )
self.view.addSubview( button )
end
end
end
With MotionAwesome you have access to all the latest icons available on the FontAwesome site.
In order to specify the icon name you can use a symbol for the name minus the 'icon-' prefix and sub out the '-' with '_'. Simple!
FontAwesome => MotionAwesome
fa-flag => :flag
fa-star-o => :star_o
Awesomization is currently in effect for UILabel and UIButton.
The method signatures following this strategy:
awesome_label = label( :icon_name, opts ) do {|comp| ... }
awesome_button = button( :icon_name, opts ) do {|comp| ... }
Options are as follows:
- size: specifies the size of the icon. To size the text portion you can set the font of your liking. If no size is specified the icon will be sized according to the active font size.
- type: :custom | :rounded. Specifies the type of UIButton to create -- For button only! -
- text: prepends some text to your decorated label or button.
- color: sets the icon color. If this is not set the icon color will match the text color if specified.
This gem was inspired by Hiroshi Horiki(@pchw) https://github.com/pchw/fontawesome
Fernand Galiana
Still work in progress. So please feel to fork or contact me if you run into issues or just want to send some good vibes...
MotionAwesome is released under the MIT license.
- 0.0.1:
- Initial drop
- 0.0.2:
- Bug fixes and cleanup
- 0.0.3:
- Mo' spring cleaning
- 0.0.4:
- Additional clean up
- 0.0.5:
- Upgrade to RM 2.0
- Upgrade to FontAwesome 3.1.1 - 302 icons. Yeah!
- 0.0.6:
- Upgrade to RM 2.16
- Upgrade to FontAwesome 4.0.3