Last Updated: February 25, 2016
· diogoandre

Use a font icon in RubyMotion

Remember to first copy your font file to the /resources directory at the root of your project

my_icon = NSMutableAttributedString.alloc.initWithString("\uf00e")
my_icon.addAttribute(NSFontAttributeName, value: NSFont.fontWithName("github-octicons",size:30), range: NSMakeRange(0, 1))

The string in initWithString will be the unicode value of the char that represents the icon you want. Most font icons offer a CSS file and you can get these values from there. Sometimes the font website will give you the unicode value, as does when you select an icon.

I've tested on a Mac app, but it should work the same on a iOS app