iOS 10, UIToolbar background color does not change

Using barTintColor does not result in the proper color I want, but the following approach worked for me in iOS 11 / Swift 4.

First, create an image of any size that a solid color of what you would like your bar to be.

After that, use the following extension:

import UIKit

extension UIToolbar {
    func setBackgroundColor(image: UIImage) {
        setBackgroundImage(image, forToolbarPosition: .any, barMetrics: .default)
    }
}

The solid color image you created will then be applied as the background of your toolbar, and should perfectly match your desired color.

In this example, I used a 1x1 image with purple: enter image description here


I was able to solve it, it's changed to this : BarTintColor, found it myself couldn't find anything in apple docs mentionning it

Use it like this : self.toolbar.barTintColor

edit : there is sometinhg mentionning it now in the GM release docs, see answer bellow