单击更改SwRevealViewController图标图像

问题描述 投票:1回答:2

enter image description here

我想将SwRevealViewController SideMenu单击按钮更改为此,当我单击它并再次按下它时恢复正常。怎么可能?我应该在哪里更改SwRevealViewController.m文件中的代码?

ios iphone xcode swrevealviewcontroller
2个回答
0
投票

将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

0
投票

//查看加载添加此内容 // 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,动画:真的)

}

© www.soinside.com 2019 - 2024. All rights reserved.