我想将导航 Controller 栏按钮项目设置为图像。
我已阅读以下内容 - Add image to a navigationItem's title
我知道如何将其设置为图像。我实际上希望将其设置为栏按钮项目内的设置齿轮(如齿轮图标)。我之前在其他应用程序中见过这个,我想知道是否有一个默认样式可以为此初始化,或者通常情况下这是否是通过上面的图像路径实现的。
如果是上面的内容,有谁知道这种(一种)默认图像样式的图标在哪里可用,或者我需要制作一个吗?
最佳答案
您是否尝试过使用UIBarButtonItem
的initWithCustomView
选项?示例代码如下所示。
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/