I am trying to customize the navigation bar in a RubyMotion application, but cannot change the font or color of the title text. I can set the background image and hue, but not the title attributes.
class AppDelegate def application(application, didFinishLaunchingWithOptions:launchOptions) @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) navigationBar = UINavigationBar.appearance #navigationBar.setBackgroundImage(UIImage.imageNamed('navigation-bar-background.png'), forBarMetrics: UIBarMetricsDefault) #navigationBar.setTintColor(UIColor.greenColor) navigationBar.setTitleTextAttributes({ UITextAttributeFont: UIFont.fontWithName('Trebuchet MS', size:24), UITextAttributeTextShadowColor: UIColor.colorWithWhite(0.0, alpha:0.4), UITextAttributeTextColor: UIColor.blueColor }) puts navigationBar.titleTextAttributes.inspect @window.rootViewController = UINavigationController.alloc.initWithRootViewController(MainMenuController.alloc.init) @window.rootViewController.wantsFullScreenLayout = true @window.makeKeyAndVisible true end end
The console output shows this for a validation instruction:
{:UITextAttributeFont=>#<UICFFont:0x963aa70>, :UITextAttributeTextShadowColor=>UIColor.color(0x0, 0.0), :UITextAttributeTextColor=>UIColor.blueColor}
So it seems that everything is set up correctly, but all I get is a standard blue navigation bar with white text.
source share