Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>drawLayer or drawRect method will not be called until you subclass UINavigationBar and call drawRect there. </p> <p>follow this code - </p> <pre><code>@implementation UINavigationBar (UINavigationBarCategory) - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx { if([self isMemberOfClass:[UINavigationBar class]]) { UIImage *image; image=[UIImage imageNamed:@"title_768.png"]; CGContextClip(ctx); CGContextTranslateCTM(ctx, 0, image.size.height); CGContextScaleCTM(ctx, 1.0, -1.0); CGContextDrawImage(ctx, CGRectMake(0, 0, self.frame.size.width, self.frame.size.height), image.CGImage); } else { [super drawLayer:layer inContext:ctx]; } } @end </code></pre> <p>And add MyNavigationBar.h and MyNavigationBar.m file in your code - </p> <p>MyNavigationBar.h - </p> <pre><code>#import &lt;Foundation/Foundation.h&gt; @interface MyNavigationBar : UINavigationBar &lt;UINavigationBarDelegate&gt; @end </code></pre> <p>MyNavigationBar.m - </p> <pre><code>#import "MyNavigationBar.h" @implementation MyNavigationBar - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // Initialization code } return self; } - (void)drawRect:(CGRect)rect { UIImage *image; image=[UIImage imageNamed:@"title_768.png"]; [image drawInRect: CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) ]; } - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{ } - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{ } @end </code></pre> <p>And now subclass your UINavigationBar with MyNavigationBar.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload