how do i access a ui button in the viewcontroller class from a function parameter?

Your code is wrong, specifically the argument types for changeIconColor. For example this should work:

class ViewController: UIViewController
    @IBOutlet weak var btnMaxAloud: UIButton!

    override func viewDidLoad()
        btnMaxAloud.tintColor = UIColor.white

    func changeIconColor(_ button: UIButton, _ color: UIColor)
        button.tintColor = color

The function changeIconColor() now takes a UIButton and UIColor as argument.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top