I am trying using the code below to set the appearance of UINavigationBar globally:
[[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];
I have successed to set the barStyle and the backGroundImage, but when I set the appearance of backButtonBack (the third line). The app crash and I get the error as below :
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_UIAppearance setBackButtonBackgroundImage:forState:barMetrics:]: unrecognized selector sent to instance 0x1dd7ea00'
How to correctly set the appearance of backButtonBack globally?
setBackButtonTitlePositionAdjustment:forBarMetrics:
belongs to UIBarButtonItem
.
Use:
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:[UIImage imageNamed:@"btn_fanhui_1"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.