我正在尝试自定义 RubyMotion 应用程序中的导航栏,但似乎无法更改标题文本字体或颜色。我可以设置背景图像和色调,但不能设置标题属性。
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
控制台输出显示了这个检查语句:
{:UITextAttributeFont=>#<UICFFont:0x963aa70>,
:UITextAttributeTextShadowColor=>UIColor.color(0x0, 0.0),
:UITextAttributeTextColor=>UIColor.blueColor}
所以看起来一切都设置正确,但我得到的只是带有白色文本的标准蓝色导航栏。