4 Replies
      Latest reply on Jun 6, 2019 3:59 AM by Claude31
      bchandresh Level 1 Level 1 (0 points)

        Hi,

        I have an label as cutomView toolbarItem. I want to change it's string value from ViewControllers.

         

        Any suggestions, how to do it?

        • Re: Change NSToolbarItem Label
          Claude31 Level 8 Level 8 (6,205 points)

          You have probably created the toolBar in IB.

           

          So, you can have an IBOutlet connected to the toolBar.

              @IBOutlet weak var tabBarCustom: UIToolbar!

           

          To change the title :

                  tabBarCustom.items?[0].title = "New name"

           

          Note: that's for IOS.

           

          On OSX, you can use similar solution (class is NSToolBar)

          tabBarCustom.items?[0].label = "New name"
            • Re: Change NSToolbarItem Label
              bchandresh Level 1 Level 1 (0 points)

              Hi Claude,

              I'm using OSX. I have a toolbar which contains NSTextField as Custom Views.

               

              1. tabBarCustom.items?[0].label = "New name"

              This works when using Icon & Text. I want to use Icon only Toolbar.

                • Re: Change NSToolbarItem Label
                  Claude31 Level 8 Level 8 (6,205 points)

                  Could you give more details ?

                   

                  This works when using Icon & Text.

                  In the toolbarItem, In the attributes inspector, you have:

                  - image

                  - label          ==> This is the one you change with

                       tabBarCustom.items?[0].label = "New name"

                  - palette label

                   

                  I want to use Icon only Toolbar.

                  What do you mean ?

                  Is it a toolbar where label is empty ? Or something else ?

                   

                  You ask: I want to change it's string value from ViewControllers.

                  What do you want to change ? The label ? Something else ?