how to enable/disable NSToolbarItem

前端 未结 4 1156
陌清茗
陌清茗 2021-01-04 13:39

I have a project that needs to disable/enable some NSToolbarItems depends on different options. I checked and found no parameter for this.

Is there a wa

4条回答
  •  盖世英雄少女心
    2021-01-04 14:15

    an easy way to do this in swift, or you could port this to objective c is to just set actions

    This Disables the item

    Mytoolbar.action = nil
    

    This reEnables it

    Mytoolbar.action = "Name of a function"
    

    In doing this you would want to replace your IBAction with function so

    @IBAction func blehbleh(sender: AnyObject){ Stuff }
    

    would be changed to

    func blehbleh(){ Stuff }
    

提交回复
热议问题