问题
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