【问题标题】:Change the navigation bar to an image将导航栏更改为图像
【发布时间】:2013-07-24 20:02:58
【问题描述】:

我的 Xcode 项目中有一个图像,它当前设置为与标签栏相同的尺寸。我通过情节提要设置了导航栏,而不是以编程方式。我希望导航栏的外观来自我的图像。我该怎么做?

【问题讨论】:

    标签: ios cocoa-touch uistoryboard


    【解决方案1】:

    代码如下:

    UIImage *image = [UIImage imageNamed:@"yourImage.png"];
    [navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
    

    【讨论】:

    • 两个错误 No known class method for selector 'setBackgroundImage:forBarMetrics:' 第二个是“未知接收器'NavigationBar';你的意思是'UINavigationBar'吗?”
    • @JonathanClendenon 试试 self.navigationBar
    • @JonathanClendenon 试试 self.navigationcontroller.navigationbar
    • 在“AppDelegate *”类型的对象上找不到新的错误属性“navigationcontroller”
    • @JonathanClendenon 你在使用导航控制器吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-16
    相关资源
    最近更新 更多