Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top