0

我正在尝试使用下面的代码来全局设置 UINavigationBar 的外观:

[[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"bg_daohang"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackButtonBackgroundImage:[UIImage imageNamed:@"btn_fanhui_1"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

我已经成功设置了barStyle和backGroundImage,但是当我设置了backButtonBack(第三行)的外观时。应用程序崩溃,我收到如下错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_UIAppearance     setBackButtonBackgroundImage:forState:barMetrics:]: unrecognized selector sent to instance 0x1dd7ea00'

如何正确设置全局 backButtonBack 的外观?

4

1 回答 1

1

setBackButtonTitlePositionAdjustment:forBarMetrics:属于UIBarButtonItem.

利用:

[[UIBarButtonItem appearance] setBackButtonBackgroundImage:[UIImage imageNamed:@"btn_fanhui_1"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
于 2013-06-25T09:02:11.537 回答