1

enter image description here

I would like to change the SwRevealViewController SideMenu click button to this when I click it and back to normal on pressing it again.How is it possible?Where Should I change the code in SwRevealViewController.m file?

Akhil Jiji
  • 185
  • 1
  • 2
  • 13
  • Why don't you change the icon when it is tapped (inside your frontVC i.e. which contains the button) and let the chips fall where they may? – NSNoob Jan 18 '16 at 06:50
  • I use barButtonitem here .. The action is perofrmed in SwRevealViewController's .m file.So I need to perform this action in its library itself,so that i can change it for all the ViewControllers at once. – Akhil Jiji Jan 18 '16 at 06:57
  • Okay. Well `- (void)revealToggleAnimated:(BOOL)animated` is called inside the library when the position is toggled. – NSNoob Jan 18 '16 at 06:59

2 Answers2

0

Add SWRevealViewControllerDelegate to your viewcontroller and implement following method.

 revealViewController.delegate = self;

-(void)revealController:(SWRevealViewController *)revealController didMoveToPosition:(FrontViewPosition)position

//check position here
if(position == FrontViewPositionLeft) {

// show normal button image (your menu view is hidden here)

}
else if(position == FrontViewPositionRight) {

  // Change button image here.
}

You can also change your button image inside this method in SWRevealViewController.m

- (void)_setFrontViewPosition:(FrontViewPosition)newPosition withDuration:(NSTimeInterval)duration
rushisangani
  • 3,195
  • 2
  • 14
  • 18
  • revealViewController.delegate = self; returns error – Akhil Jiji Jan 18 '16 at 07:14
  • you can refer this link. https://github.com/John-Lluch/SWRevealViewController and explore RevealControllerStoryboardExample2 – rushisangani Jan 18 '16 at 08:58
  • @AkhilJiji It should not be returning error. It should be giving a warning instead. To get rid of that warning, Make your viewcontroller to be delegate of SWRevealViewController. – NSNoob Jan 18 '16 at 09:17
0

//View Did load add this
// Swift 4.2

func viewDidLoad() {

super.viewDidLoad() let leftMenuItem = UIBarButtonItem(image: UIImage(named: "menu"), style: .plain, target: revealViewController, action: #selector(SWRevealViewController.revealToggle(_:))) navigationItem.setLeftBarButton(leftMenuItem, animated: true)

}