swiftnsbuttonnstouchbarnscontrol

Hide NSTouchBar button


I'm working on a personal project in swift (for macOS app) and I want to make a NSbutton (Touch Bar button) and hide it.
Is there a possible way to do this?


Solution

  • I found the answer!
    Just write:

    <button_name>.isHidden = true
    

    or if you want to disable and not hide:

    <button_name>.isEnabled = false
    

    In my case I had button that called "submitButton" so I wrote:

    submitButton.isHidden = true
    

    and when I wanted it to appear I wrote:

    submitButton.isHidden = false