Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>Swift 3 (iOS 10)</h1> <h2>Transparent <code>UIToolbar</code></h2> <pre><code>self.toolbar.setBackgroundImage(UIImage(), forToolbarPosition: .any, barMetrics: .default) self.toolbar.setShadowImage(UIImage(), forToolbarPosition: .any) </code></pre> <h2>Transparent <code>UINavigationBar</code></h2> <pre><code>self.navigationBar.setBackgroundImage(UIImage(), for: .default) self.navigationBar.shadowImage = UIImage() self.navigationBar.isTranslucent = true </code></pre> <hr> <h1>Swift &lt; 3</h1> <h2>Transparent <code>UIToolbar</code></h2> <pre><code>self.toolbar.setBackgroundImage(UIImage(), forToolbarPosition: UIBarPosition.Any, barMetrics: UIBarMetrics.Default) self.toolbar.setShadowImage(UIImage(), forToolbarPosition: UIBarPosition.Any) </code></pre> <h2>Transparent <code>UINavigationBar</code></h2> <pre><code>self.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default) self.navigationBar.shadowImage = UIImage() self.navigationBar.translucent = true </code></pre> <hr> <h1>Objective-C</h1> <h2>Transparent <code>UIToolbar</code></h2> <pre><code>[self.toolbar setBackgroundImage:[UIImage new] forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault]; [self.toolbar setShadowImage:[UIImage new] forToolbarPosition:UIBarPositionAny]; </code></pre> <hr> <h2>Transparent <code>UINavigationBar</code></h2> <pre><code>[self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; self.navigationBar.shadowImage = [UIImage new]; self.navigationBar.translucent = YES; </code></pre> <hr> <h1>Discussion</h1> <p>Setting <code>translucent</code> to <code>YES</code> on the navigation bar does the trick, due to a behavior discussed in the <a href="https://developer.apple.com/library/ios/documentation/uikit/reference/UINavigationBar_Class/Reference/UINavigationBar.html#//apple_ref/occ/instp/UINavigationBar/translucent"><code>UINavigationBar</code></a> documentation. I'll report here the relevant fragment:</p> <blockquote> <p>If you set this property to <code>YES</code> on a navigation bar with an opaque custom background image, the navigation bar will apply a system opacity less than 1.0 to the image.</p> </blockquote> <hr> <h1>Final result</h1> <p><img src="https://i.stack.imgur.com/O4nPnl.png" alt="final result"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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