How to apply gradient colors on UINavigationBar?
<p>I am trying to apply <a href="https://github.com/ViccAlexander/Chameleon#gradient-colors" rel="nofollow">Gradient Colors</a> of <a href="https://github.com/ViccAlexander/Chameleon" rel="nofollow">Chameleon</a> library on UINavigationBar. <a href="https://www.raywenderlich.com/108766/uiappearance-tutorial" rel="nofollow">This</a> tutorial suggests that we can apply theme to all instances of UINavigationBar by using <code>UINavigationBar.appearance()</code>. So this means that I can do something like following to set the gradient:</p>

<pre><code>UINavigationBar.appearance().barTintColor = UIColor(gradientStyle:UIGradientStyle.LeftToRight,  
  withFrame: CGRectMake(0, 0, UINavigationBar.appearance().frame.width, UINavigationBar.appearance().frame.height), 
  andColors:[UIColor.flatMagentaColorDark(), UIColor.flatLimeColor()])
</code></pre>

<p>But the problem is that I am not able to get the height and the width of the UINavigationBar instance. It is required for <code>withFrame</code> parameter in the above code. Is there any way to apply gradients to all instances in one shot?</p>