我想将SwRevealViewController SideMenu单击按钮更改为此,当我单击它并再次按下它时恢复正常。怎么可能?我应该在哪里更改SwRevealViewController.m文件中的代码?
将SWRevealViewControllerDelegate添加到viewcontroller并实现以下方法。
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.
}
您还可以在SWRevealViewController.m中更改此方法中的按钮图像
- (void)_setFrontViewPosition:(FrontViewPosition)newPosition withDuration:(NSTimeInterval)duration
//查看加载添加此内容 // 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,动画:真的)
}