小编JWr*_*ght的帖子

RubyMotion中的UINavigationBar外观无法正常工作

我正在尝试在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
Run Code Online (Sandbox Code Playgroud)

控制台输出显示了以下对于inspect语句:

{:UITextAttributeFont=>#<UICFFont:0x963aa70>,
 :UITextAttributeTextShadowColor=>UIColor.color(0x0, 0.0),
 :UITextAttributeTextColor=>UIColor.blueColor}
Run Code Online (Sandbox Code Playgroud)

所以看起来一切都设置正确,但我得到的只是带有白色文字的标准蓝色导航栏.

objective-c ios ios5 rubymotion

4
推荐指数
1
解决办法
1336
查看次数

标签 统计

ios ×1

ios5 ×1

objective-c ×1

rubymotion ×1