UIButton Changing Foreground, and Background, Colors

The goal is to have the background, and foreground, colors show the current state of a UIButton on a storyboard file. The attempt to do that is done with this code:

    var toggleLight: Bool = false
    @IBAction func toggleLight(_ sender: UIButton) {
        if( toggleLight ){
            toggleLight = false
            sender.baseBackgroundColor = UIColor.black
            sender.baseForegroundColor = UIColor.white
        }else{
            toggleLight = true
            sender.baseBackgroundColor = UIColor.white
            sender.baseForegroundColor = UIColor.black

        }
        tableView.reloadData()
    }

I get these errors:

Value of type 'UIButton' has no member 'baseBackgroundColor'
Value of type 'UIButton' has no member 'baseForegroundColor'

I do not understand this because in file "UIKit.UIButton" I see:

extension UIButton {
...
   public var baseForegroundColor: UIColor?
   public var baseBackgroundColor: UIColor?
...
}

What has gone wrong there?