Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIButton的外观是否也会更改UIBarButton图像?_Ios_Objective C_Uibutton_Uibarbuttonitem_Uiappearance - Fatal编程技术网

Ios UIButton的外观是否也会更改UIBarButton图像?

Ios UIButton的外观是否也会更改UIBarButton图像?,ios,objective-c,uibutton,uibarbuttonitem,uiappearance,Ios,Objective C,Uibutton,Uibarbuttonitem,Uiappearance,我正在使用这段代码 [[UIButton appearance] setBackgroundImage:[UIImage imageNamed:@"button.png"] forState:UIControlStateNormal]; 更改ui按钮的外观。这很好地工作,并且不会影响UIBarButtonItem,除了其中一个按钮(唯一一个不是自动生成的“后退”按钮)之外,并且仅在最初。当您触摸按钮时,它会恢复为没有背景图像 有问题的按钮是UIBarButton,而不是UIButton(除非两

我正在使用这段代码

[[UIButton appearance] setBackgroundImage:[UIImage imageNamed:@"button.png"] forState:UIControlStateNormal];
更改
ui按钮的外观。这很好地工作,并且不会影响UIBarButtonItem,除了其中一个按钮(唯一一个不是自动生成的“后退”按钮)之外,并且仅在最初。当您触摸按钮时,它会恢复为没有背景图像

有问题的按钮是
UIBarButton
,而不是
UIButton
(除非两者都是,在这种情况下,其他
UIBarButton
也会受到影响)

线索可能是,其他未受影响的
UIBarButton
都是由我在故事板中生成的,而不是我创建的


这一定是api中的错误?

使用
setTintColor
解决。是一个api错误,从那时起可能已经被修复了

你能发布生成
uibarbuttoneim
s的代码吗?唉,正如我试图传达的那样,它们是在故事板中定义的,因此它们也可能是由巫毒魔法生成的。我解决这个问题的方法是使用setTintColor。唯一需要的代码应该是应用程序委托中的一行代码和带有一些导航示例的故事板。这真的很旧,但谢谢:)