Search code examples
objective-crubymotion

Change font for UIBarButtonItem


I am building an iOS app using Rubymotion and I need to set the font family to a custom font for a button in the navigation bar (UIBarButtonItem). I know I do it like this in Objective-C but how is it done in Ruby?

[buttonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIFont fontWithName:@"Helvetica-Bold" size:26.0], UITextAttributeFont,nil] forState:UIControlStateNormal];

Thankful for all help!


Solution

  • I think this will do it. I don't have my Mac handy to test this out so give it a shot and let us know how it goes.

    buttonItem.setTitleTextAttributes({UITextAttributeFont => UIFont.fontWithName("Helvetica-Bold", size:26.0)}, forState:UIControlStateNormal)