ios - Customizing the BackBarButtonItem -
i'm trying customize backbarbuttonitem custom image (the text 'back' included in image), here current result:
does know why might happening?
here code on viewdidload (actually runs both on parent controller , again on new controller has button)
uiimage *backbuttonimage = [uiimage imagenamed:@"graphics/shared/navigation_back_button.png"]; uibarbuttonitem *backbutton = [[uibarbuttonitem alloc] initwithimage:backbuttonimage style:uibarbuttonitemstyleplain target:nil action:nil]; self.navigationitem.backbarbuttonitem = backbutton; edit: i'm using ios 5 way! maybe appearance proxy usable far when tried use button stuff (in appdelegate) app simple crashes.
okay solved issue, using bit of rough trick, @ least works. if come more standard solution though, please let me know!
here's code:
uiimage *backbuttonimage = [[uiimage imagenamed:@"graphics/shared/navigation_back_button.png"] resizableimagewithcapinsets:uiedgeinsetsmake(0, 0, 0, 0)]; [[uibarbuttonitem appearance] setbackbuttonbackgroundimage:backbuttonimage forstate:uicontrolstatenormal barmetrics:uibarmetricsdefault]; [[uibarbuttonitem appearance] setbackbuttontitlepositionadjustment:uioffsetmake(0, backbuttonimage.size.height*2) forbarmetrics:uibarmetricsdefault]; this in appdelegate's method:
- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions to stop stretching when using background, used idea ios 5: how implement custom (image) button
but tweaked rather having set-
self.title = @" "; on every view load (and might mess nav bar title itself)
i set offset 'back' button text twice image height, you'll never see it.
why go trouble, rather use left button item it's own method pop view controller?
the main reason lose standard button sliding animation changing views. also, means don't need use custom button or write custom method going back. works.
hope solves else's problem too, know stuck on 3 hours!
Comments
Post a Comment