Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7 Back Button Arrow Vertical Alignment

On iOS 7, is there any way to change the back button arrow's vertical alignment? I can only change the vertical alignment of the title and nothing in UIBarButtonItem's appearance suggest that the arrow vertical alignment can be changed.

See the following example:

example

like image 800
Aaron Wojnowski Avatar asked Sep 23 '13 04:09

Aaron Wojnowski


1 Answers

I think the best way to reach your goal is setting the UINavigationBars backIndicatorImageto an arrow-image with space around it. You can mask your image, so the text is able to flow into parts of the image.

UINavigationBar *navigationBar = ...;

navigationBar.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Activity" style:UIBarButtonItemStylePlain target:nil action:nil];

navigationBar.backIndicatorImage = [UIImage imageNamed:@"arrow-image"];
navigationBar.backIndicatorTransitionMaskImage = [UIImage imageNamed:@"arrow-image-mask"];

AppCoda wrote a great article about customizing the UINavigationBarin iOS7. It's worth reading:
http://www.appcoda.com/customize-navigation-status-bar-ios-7/

As the docs say you have to set BOTH properties to get this up and running: https://developer.apple.com/library/ios/documentation/uikit/reference/uinavigationbar_class/Reference/UINavigationBar.html#//apple_ref/occ/instp/UINavigationBar/backIndicatorImage

like image 194
Sascha Manuel Hameister Avatar answered Oct 24 '22 01:10

Sascha Manuel Hameister