1, change the height
New categories for customizing Uinavigationbar:
[CPP]View Plaincopy
- //uinavigationbar+backgoundimage.h   
- #import <Foundation/Foundation.h>
- @interface Uinavigationbar (Backgoundimage)
- @end
in the implementation of the new category, methods that overwrite the original class-(void) DrawRect: (cgrect) Rect:
[CPP]View Plaincopy
- //UINAVIGATIONBAR+BACKGOUNDIMAGE.M
- #import "Uinavigationbar+backgoundimage.h"
- @implementation Uinavigationbar (Backgoundimage)
- - (void ) layoutsubviews {
- cgrect barframe = self.frame;
- barframe.size.height = 100.0; //New height &NBSP;&NBSP;
- Self.frame = Barframe;
- }
- //Actually only need to overwrite the method on the line, change the self.frame.size.height to 100.0 OK
- - (void ) DrawRect: (CGRect) rect {
- uiimage *image = [uiimage imagenamed:@< Span class= "string" style= "margin:0px; padding:0px; Border:none; Color:blue; Background-color:inherit ">" logo.png " ];&NBSP;&NBSP;
- [Image drawinrect:cgrectmake (0, 0, Self.frame.size.width, self.frame.size.height)];
- }
- @end
The height of the Navigationbar in the project can be found to have changed.
2, next change the background image, (refer to http://stackoverflow.com/questions/8375092/ Xcode4-2-storyboard-navigation-controller-how-to-set-custom-image-for-uinavig):
The delegate method in XXXAPPDALEGATE.M:
[CPP]View Plaincopy
- - ( bool ) Application: (uiapplication *) Application didfinishlaunchingwithoptions: (NSDictionary *) launchoptions
- {&NBSP;&NBSP;
- //......&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;
- return yes;
- }
"Return YES" before adding the code:
[CPP]View Plaincopy
- [[Uinavigationbar appearance] setbackgroundimage:[uiimage imagenamed:@"logo.png"] Forbarmetrics:uibarmetricsdefault]; //this adds the image
success.
The height of the 1th step can be directly taken to the height of the picture, so it is more convenient.
iOS development changes the height and background picture of Uinavigationcontroller Uinavigationbar