【问题标题】:add subview in navigation bar ios7在导航栏中添加子视图ios7
【发布时间】:2014-05-19 06:39:46
【问题描述】:

我想在导航栏上添加两个按钮和一个图像视图。我编写了以下用于添加图像的代码,但它不起作用。

 UIView *customView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];
 UIImageView *logo=[[UIImageView alloc]init];
 logo.image=[UIImage imageNamed:@"sdas.jpeg"];
[customView addSubview:logo];
self.navigationController.navigationItem.titleView=customView;

【问题讨论】:

  • 可以隐藏导航栏,可以自定义UIView的UiNavigation bar大小。然后你可以根据需要添加子视图。
  • 不,不想隐藏,我想全部显示在导航栏上
  • 我建议你一个方法,现在取决于你:)

标签: ios ios7


【解决方案1】:

尝试使用initWithCustomView 来添加按钮,如here 描述的那样,并使用this way 来添加setBackgroundImage:forMetrics

【讨论】:

  • 我想在中间添加两个单独的按钮和一个 uiimage,但我什至看不到图像,请帮助
  • 分步执行,使用第一个链接创建一个按钮并将其分配给 leftbarbutton 项。
  • 很高兴看到这个。 :) 如果任何答案对您有所帮助,请将其标记为答案,以便对未来的访问者有所帮助。
【解决方案2】:

试试这个

self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Your Image Name"]];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-23
    相关资源
    最近更新 更多