How do I insert code in ViewDidAppear and ViewDidDisappear From other class

前端 未结 2 1754
广开言路
广开言路 2021-01-23 08:22

I want to change button image whenever UISideMenuNavigationController Appear Or Disappear.

This is the class that has a button.

class MenuViewController         


        
2条回答
  •  暖寄归人
    2021-01-23 08:49

    1. Your MenuViewController class could have a function that changes the image on the button. Eg, func changeButtonMenuImage().
    2. Your 'UISideMenuNavigationController' (or a subclass of it) could have some sort of connection to the MenuViewController either as a property, instance variable or an IBOutlet. Eg, @IBOutlet var menuController: MenuViewController
    3. Then your viewDidAppear and viewDidDisappear can call it's function. Eg, menuController.changeButtonMenuImage()

提交回复
热议问题