I know how to set a navigation bar background color (with barTintColor), but now I am working on an iOS app that calls for a horizontal gradient (not the typical vertical gradient).
How can I create a navigation bar with a horizontal gradient background?
You can use that :
for ios 7 navigation bar height is 64px
If you want to programmatically set the gradient of a given UINavigationBar I have a solution for you.
First setup a
CAGradientLayer
with your desired colors and locations.Then grab the UImage for that layer.
Set the
gradientImage
as the backgroundImage for yourUINavigationBar
.Swift Solution:
Updated @JulianM answer for iOS 10 / swift 3.0: