Custom back button in UINavigationController

前端 未结 10 1824
伪装坚强ぢ
伪装坚强ぢ 2020-12-28 16:59

For an application I\'m developing, I need to display a custom back button in a navigation bar. I have the button asset as a PNG image, and I\'m writing this code:



        
10条回答
  •  Happy的楠姐
    2020-12-28 17:43

    Starting with iOS 5, this is simple:

    [[UIBarButtonItem appearance]
                setBackButtonBackgroundImage:[UIImage imageNamed:@"back_button.png"]
                forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    

    You can place that in your app delegate and it will set the background image to all back buttons in the app (for that control state and bar metrics, of course).

提交回复
热议问题