【问题标题】:How can I set a background image to navigation controller bottom tool bar?如何将背景图像设置为导航控制器底部工具栏?
【发布时间】:2010-07-13 18:41:37
【问题描述】:

我有一个导航控制器,我想在底部工具栏设置一个图像,我想向它添加按钮,我该怎么做?

【问题讨论】:

  • 你的意思是工具栏吗?你的帖子确实说标签栏,但你描述它的方式让我觉得你在谈论工具栏。
  • 是的,我如何以编程方式在其上添加按钮

标签: iphone xcode navigation


【解决方案1】:

通常最好稍微阅读一下文档,因为它通常会告诉您要做的事情。

UIToolbar 文档here

阅读本文后,您可以看到有一个 setItems,它采用 UIBarButtonItems 的 NSArray。

您最好的选择可能是这些方面的东西。假设您希望能够为按钮使用图像。如果没有,请告诉我,我可以更新答案。

UIToolbar *toolbar = [[UIToolbar alloc] init];
NSMutableArray *arrayOfButtons = [NSMutableArray new];

UIImage *image = [UIImage imageNamed:@"image.png"];
UIBarButtonItem *button1 = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStyleBlack target:self action:@selector(doSomething)];

[array addObject:button1];

[toolbar setItems:arrayOfButtons];

【讨论】:

  • 是的,对于我要添加图像的按钮和工具栏也是如此。我的意思是我想将我的图像视为工具栏,因为这些按钮将在那里
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-01-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-09
相关资源
最近更新 更多