Created
March 22, 2015 17:08
-
-
Save MoathOthman/c6b0729f45edbac1a46f to your computer and use it in GitHub Desktop.
Custom UINavigationController back button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Snippet From Apple sample Code | |
UIImage *backButtonBackgroundImage = [UIImage imageNamed:@"back"]; | |
// The background should be pinned to the left and not stretch. | |
float margin = 12.0; | |
backButtonBackgroundImage = [backButtonBackgroundImage resizableImageWithCapInsets:UIEdgeInsetsMake(0, backButtonBackgroundImage.size.width - margin, 0, 0)]; | |
id appearance = [UIBarButtonItem appearanceWhenContainedIn:[ | |
CustomBackButtonNavController class], nil]; | |
[appearance setBackButtonBackgroundImage:backButtonBackgroundImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; | |
UIBarButtonItem *backBarButton = [[UIBarButtonItem alloc] initWithTitle:@" " style:UIBarButtonItemStylePlain target:nil action:nil]; | |
self.navigationItem.backBarButtonItem = backBarButton; | |
Just one note : the image you use may have different size an though needs different margin Value ; | |
Just another: CustomBackButtonNavController can be replaced with UINavigationController in case you are using the same back button all over the app as in my most cases :) . | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment