title: UINavigationController with custom shape navigation Bar
body: <p>I'm trying to create a custom UINavigationBar with a custom shape, like this (ignore transparency)</p>
  
  <p><img src="https://i.stack.imgur.com/WkVzi.png" alt="enter image description here"></p>
  
  <p>As you can see, this UINavigationBar has a custom shape and I'm trying to replicate it.</p>
  
  <p>Looking around I found <a href="https://stackoverflow.com/questions/19878288/ios-custom-shape-navigation-bar">this response</a>, where it explains the firsts steps I followed.</p>
  
  <p>1) I created a subclass of UINavigationBar called CustomNavigationBar.
  2) I overrode the sizeThatFits method like this:</p>
  
  <pre><code>- (CGSize) sizeThatFits:(CGSize)size
  {
    return CGSizeMake(320.0, 70.0);
  }
  </code></pre>
  
  <p>3) And here is where I'm lost...</p>
  
  <p>In the previous answer is said that UIBezierPath can be used to create a custom shape (even with curves) and then applied as a mask. I tried this overriding drawRect but all i get is a big black navigation bar (my bar color is set to red).</p>
  
  <p><strong>EDIT: my draw was wrong, this is the correct one</strong></p>
  
  <pre><code>- (void)drawRect:(CGRect)rect
  {
    UIBezierPath *path = [[UIBezierPath alloc] init];
    [path moveToPoint:CGPointZero];
    [path addLineToPoint:CGPointMake(320.0, 0.0)];
    [path addLineToPoint:CGPointMake(320.0, 50.0)];
    [path addQuadCurveToPoint:CGPointMake(0.0, 50.0) controlPoint:CGPointMake(160.0, 90.0)];
    [path closePath];
  
    [[UIColor redColor] setFill];
  
    [path fill];
  }
  </code></pre>
  
  <p><strong>EDIT:</strong> As said below, my code had some errors and now it draws something.</p>
  
  <p><img src="https://i.stack.imgur.com/l8N0A.jpg" alt="enter image description here"> </p>
  
  <p>As you can see, the UIBezierPath defines the shape correctly but, there is some new problems:</p>
  
  <p>1) The status bar is completely black, nothing is rendered there, even if I change his color to light, it doesn't show nothing. What am I missing?</p>
  
  <p>2) Due to the sizeThatFits method, there's still some black part left. Is there any way to make that part transparent?</p>
  
  <p>Thanks to all!</p>
  
  <p><strong>EDIT 2</strong>: well, I totally changed my perspective about this issue and I think i'm getting close to a solution. Now I'm trying to use a transparent png file as background, but still need to increase it's height, so right now this is my code.</p>
  
  <pre><code>- (CGSize) sizeThatFits:(CGSize)size
  {
     return [[UIImage imageNamed:@"Layer3"] size];
  }
  
  - (void)drawRect:(CGRect)rect
  {
    [self setClipsToBounds:NO];
    UIImage *image = [UIImage imageNamed:@"Layer3"];
    [image drawInRect:rect];
  }
  </code></pre>
  
  <p>Simpler ,right? Obviously "Layer3" is the name of my transparent png image. But now, this is what I'm getting.</p>
  
  <p><img src="https://i.stack.imgur.com/UtSKF.png" alt="enter image description here"></p>
  
  <p>As you can see, the status bar is not covered with the png image. </p>
  
  <p>What am i missing now?</p>
  
  <p>Thanks!</p>