UINavigationController

The left return button of the navigation bar controller can be set as a picture if necessary , It's impossible to use the system alone , Need to reload the navigation bar controller of the system , Replace before the controller comes out leftBarButtonItem Talent .

notes : This guy in the following link is right NavigationViewController All the customization that can be done is explained

http://beyondvincent.com/blog/2013/11/03/120-customize-navigation-status-bar-ios-7/#5

Source code is as follows :

CustomNavigationViewController.h + CustomNavigationViewController.m

#import <UIKit/UIKit.h>
@interface CustomNavigationViewController : UINavigationController
@end
#import "CustomNavigationViewController.h"
#pragma mark - Support ARC And non ARC
#if __has_feature(objc_arc)
#define RELEASE(obj)
#define AUTO_RELEASE(obj)
#else
#define Release(obj) [obj release]
#define Autorelease(obj) [obj autorelease]
#endif // Judge whether it is iOS7
#define iOS7 \
([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) @interface CustomNavigationViewController () @end @implementation CustomNavigationViewController #pragma mark - Override by overloading the parent class
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
// First in Controller
[super pushViewController:viewController animated:animated]; // Replace leftBarButtonItem
if (viewController.navigationItem.leftBarButtonItem== nil && [self.viewControllers count] > ) {
viewController.navigationItem.leftBarButtonItem =[self customLeftBackButton];
}
} #pragma mark - Custom back button image
-(UIBarButtonItem*)customLeftBackButton{ UIImage *image = [UIImage imageNamed:@"back.png"]; UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; backButton.frame = CGRectMake(, , image.size.width, image.size.height); [backButton setBackgroundImage:image
forState:UIControlStateNormal]; [backButton addTarget:self
action:@selector(popself)
forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
Autorelease(backItem); return backItem;
} #pragma mark - Back button event (pop)
-(void)popself
{
[self popViewControllerAnimated:YES];
} #pragma mark - Set navigation background with pictures
+ (void)initialize
{
// Take out the object that sets the theme
UINavigationBar *navBar = [UINavigationBar appearance]; // Set the background image of the navigation bar
NSString *navBarBg = nil;
if (iOS7)
{
navBarBg = @"NavBar64";
navBar.tintColor = [UIColor whiteColor];
}
else
{
navBarBg = @"NavBar";
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}
[navBar setBackgroundImage:[UIImage imageNamed:navBarBg] forBarMetrics:UIBarMetricsDefault]; // Title Color
[navBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
} @end

heavy load UINavigationController Set the text of the return button on the left to more related articles of the picture

  1. How to modify UINavigationController、UINavigationBar in navigationItem left “ return ” The name of the button

    If we're from title by “ home page ” The page of A Click to enter a sub page B, So on the page B In the upper left corner of the will be a display called “< home page ” The button . Suppose this page A It's called “ You are the most beautiful cloud in my world ”, That's on the page B ...

  2. UINavigationController The back button removes the text

    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetric ...

  3. iOS 11 Use method to replace (Method Swizzling), Remove the text from the return button in the navigation bar

    Method 1 : Set up BarButtonItem The text style of is transparent color , The code is as follows : [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegro ...

  4. iOS I'm not allowed to take part in the project --appearance The magic effect of , Set the navigation bar back button again , The encapsulation of the left and right buttons in the navigation bar ( Clever use of classification )

    One .UI_APPEARANCE_SELECTOR In the lottery appearance The usage of has not been understood , This time through the teacher's explanation in the second project , I've learned a lot about appearance The role and use of ...

  5. Customize iOS7 Navigation bar background , Title and back button text color

    stay iOS7 Next , Default navigation bar background , The color is like this , Next, let's customize , If you just change the background and color , The code will be simple , No need for complicated customization View To replace leftBarItem Change the background and text of the navigation bar Col ...

  6. 【 turn 】 Customize iOS7 Navigation bar background , Title and back button text color -- Good good !!

    Original website :http://blog.csdn.net/mad1989/article/details/41516743 stay iOS7 Next , Default navigation bar background , The color is like this , Next, let's customize , If you're just more ...

  7. 【 turn 】 Customize iOS7 Navigation bar background , Title and back button text color

    original text :http://blog.csdn.net/mad1989/article/details/41516743 UIBarButtonItem,navigationItem,backBarButto ...

  8. iOS Navigation bar background , Title and back button text color

    stay iOS7 Next , Default navigation bar background , The color is like this , Next, let's customize , If you just change the background and color , The code will be simple , No need for complicated customization View To replace leftBarItem Change the background and text of the navigation bar Col ...

  9. Swift - Modify navigation bar “ return ” Button text , Icon

    Swift - Modify navigation bar “ return ” Button text , Icon 2015-11-27 09:13 Release :hangge Browse :4037   It's often used in projects  UINavigationController  Guide each page ...

Random recommendation

  1. win10 Experience

    I heard recently that win10 It's the official version , Microsoft seems to be win10 I put a lot of expectations into it , I don't know how , True knowledge comes from practice , Xiao Bian, let's have a personal experience today ! In fact, a lot of people are right about win8 dissatisfied , Mainly because win8 The compatibility of is not satisfactory , Xiaobian's electricity ...

  2. Android introduction :Activity Four startup modes

    One . Introduction to startup mode Boot mode is simply Activity Strategy at startup , stay AndroidManifest.xml The label in android:launchMode Property settings : The startup mode is 4 Kind of , Respectively standa ...

  3. mysql_connect and mysql_pconnect difference ( turn )

    php in mysql_pconnect() How to implement : Actually mysql_pconnect() I didn't do much of it , The only thing it does is php Not active after running close fall mysql The connection of .mysql_pcon ...

  4. Angular Dynamic generation html in ng-click Invalid

    bodyApp.controller('customersCtrl', function ($scope, $http, cfpLoadingBar,$compile) { $scope.test = ...

  5. ( turn )SVN Detailed explanation

    Original address :http://www.weixingon.com/s/visualsvn+%E4%B8%AD%E6%96%87 1. Application scenarios of several agent management tools A. If your project is 5-6 A small team of people , So use V ...

  6. stay Win7 Install the assembly to GAC

    original text : stay Win7 Install the assembly to GAC Microsoft to improve system security , since Vista After the launch , stay Windows A new thing has been added to the system ——UAC(User Account Control), Such a new technology makes a lot of exercises ...

  7. iOS use AFN Upload pictures to java backstage

    -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { AFHTTPSessionMana ...

  8. mybatis And spring Integrate ( Based on the configuration file )

    This article mainly introduces how to mybatis and spring Use it together , I use mybatis3.05 + spring3.1.0M2 , Use dbcp As a database connection pool . 1. Write data access interface (UserDa ...

  9. Android Stutio Use in java8 Of Lambda expression

    Reprint please indicate the source : http://blog.csdn.net/xmxkf/article/details/51532028 This article from the :[openXu The blog of ] Catalog : Why use Lambda expression Give Way A ...

  10. C The basic data type length of a language

    PS: The following is in Xcode Editor for 64 Test results in bit environment , It's online about 64 Bit and 32 There are differences among different data types , Please help yourself. online search. main.m #import <Foundation ...