ios - navcontroller - 将导航项设置为图像

标签 ios ios5 uinavigationcontroller uinavigationbar uinavigationitem

我想将导航 Controller 栏按钮项目设置为图像。

我已阅读以下内容 - Add image to a navigationItem's title

我知道如何将其设置为图像。我实际上希望将其设置为栏按钮项目内的设置齿轮(如齿轮图标)。我之前在其他应用程序中见过这个,我想知道是否有一个默认样式可以为此初始化,或者通常情况下这是否是通过上面的图像路径实现的。

如果是上面的内容,有谁知道这种(一种)默认图像样式的图标在哪里可用,或者我需要制作一个吗?

最佳答案

您是否尝试过使用UIBarButtonIteminitWithCustomView选项?示例代码如下所示。

UIBarButtonItem *aButton = [[UIBarButtonItem alloc] initWithCustomView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"settings.png"]]];

另一种方法是,

UIBarButtonItem *aButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"settings.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(buttonTapped)];

关于ios - navcontroller - 将导航项设置为图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12808992/

相关文章:

ios - 以纵向或横向拍摄照片并设置为方向受限于捕获方向的 View ?

ios - 在 Objective-C 中将字符串转换为 unicode

ios - 魔法记录不保存

swift - 呈现 UITabBarController 的最佳实践

ios - 在 iOS 13 上隐藏导航栏分隔线

ios - 不理解 NSOperationQueue 序列

ios - 通用应用程序 Splitviewcontroller

c++ - 为 iOS 5.0 编译/链接 FreeImage

ios - 当上一个 View 来自导航 Controller 时如何保留 TabBar 界面

ios - 主细节 uisplitViewController 和 UINavigationController View