Change SwRevealViewController Icon Image on Click

拜拜、爱过 提交于 2019-12-11 10:09:28

问题


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?


回答1:


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



回答2:


//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)

}



来源:https://stackoverflow.com/questions/34848671/change-swrevealviewcontroller-icon-image-on-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!