How to draw a transparent UIToolbar or UINavigationBar in iOS7
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
In iOS 7, transparent bars became part of the new visual style, but getting a truly clear UINavigationBar or UIToolbar took more than setting one color property. You usually needed to remove the default background image, remove the shadow image, and keep the bar translucent so content could show through.
What "transparent" means for iOS bars
In practice, there are two related effects. A translucent bar lets background content appear underneath with the system blur style. A fully transparent-looking bar removes the default chrome almost entirely so the content behind it becomes visually dominant.
The important part is that barTintColor = [UIColor clearColor] alone is usually not enough. The navigation bar and toolbar still draw their own background and shadow unless you replace those assets.
A practical setup in Objective-C
The standard technique is to provide an empty background image and an empty shadow image, then keep the bar translucent.
This removes the standard bar artwork while preserving the translucent behavior that lets the interface feel layered instead of boxed in.
Why layout adjustment matters
Once the bar becomes transparent, your content may extend underneath it. That is often the desired effect, but it changes how the top of the view should be laid out. On iOS 7, this is where developers ran into overlapping titles, hidden buttons, or scroll views that started at the wrong vertical offset.
If the content should flow under the bar, keep the extended layout behavior and adjust insets appropriately. If the content should start below the bar, disable that extension or add the correct top inset manually.
The visual styling and the layout behavior are linked. A transparent bar without matching layout work usually looks broken rather than polished.
Toolbar and navigation bar differences
The same general trick works for both controls, but the APIs are not identical. UINavigationBar uses setBackgroundImage:forBarMetrics: and setShadowImage:. UIToolbar uses the toolbar-position variant of those methods. The concepts are the same even though the signatures differ.
That is why developers often think one bar "supports transparency" and the other does not. In reality, both can be styled this way, but each one needs the correct API calls.
Think about legibility
Making a bar transparent is easy to overdo. If the content behind the bar is visually busy, the title and bar button items can become hard to read. In that case, use tint colors deliberately or choose a semi-transparent background instead of a completely clear one.
Transparency is a design tool, not automatically a better design.
Common Pitfalls
- Setting only
barTintColorto clear and expecting the default background and shadow to disappear. - Forgetting the shadow image, which leaves a visible line even after the background looks clear.
- Making the bar transparent without adjusting content layout or scroll view insets.
- Assuming
UINavigationBarandUIToolbaruse the exact same styling API. - Ignoring contrast and ending up with unreadable titles or buttons over busy content.
Summary
- In iOS 7, transparent bars usually require a clear background image plus a clear shadow image.
- Keep the bar translucent so content can visually show through.
- A clear-looking bar often changes layout because content may extend underneath it.
- '
UINavigationBarandUIToolbaruse similar ideas but different method signatures.' - Always check legibility after removing the default bar chrome.
Related reading
- How to draw border around a UILabel?
- How to draw border on just one side of a linear layout?
- How to easily resize/optimize an image size with iOS?
- How to Edit Empty Spaces of Left, Right UIBarButtonItem in UINavigationBar iOS 7
- How to embed small icon in UILabel
- How to emulate GPS location in the Android Emulator?
- How to enable back/left swipe gesture in UINavigationController after setting leftBarButtonItem?
- How to Enable Internal App Sharing for Android?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.