Suhas Aithal
Suhas Aithal

Reputation: 852

Tint Color works with native colors but not with the color from pattern image

I am theaming the navigation bar back button with the navigation bar tint color it works when I use native colors and it fails when I use custom color from an image.

working code :

self.navigationController?.navigationBar.tintColor = UIColor.orange

Not working code:

let color = UIColor.init(patternImage: someImage)
self.navigationController?.navigationBar.tintColor = color

Can someone show some light?

Upvotes: 0

Views: 269

Answers (2)

Suhas Aithal
Suhas Aithal

Reputation: 21

You cannot use pattern color for tint color.

Refer the following link: https://developer.apple.com/documentation/uikit/uiview/1622467-tintcolor

look for this note:

Important

If you attempt to use a pattern color as a tint color, the system raises an exception.

Upvotes: 2

JAINESH DOSHI
JAINESH DOSHI

Reputation: 268

If you have a image then please set image in navigationbar as a background image. Like :

self.navigationController?.navigationBar.setBackgroundImage(#imageLiteral(resourceName: "NavigationBackground"), for: .default)

Hope this is helpful.

Upvotes: 0

Related Questions