单击更改SwRevealViewController图标图像

时间:2016-01-18 06:43:34

标签: ios iphone xcode swrevealviewcontroller

enter image description here

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

2 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

//查看加载是否添加了此内容
// Swift 4.2

func viewDidLoad(){

super.viewDidLoad()   让leftMenuItem = UIBarButtonItem(image:UIImage(named:“ menu”),样式:.plain,目标:revealViewController,操作:#selector(SWRevealViewController.revealToggle(_ :)))         navigationItem.setLeftBarButton(leftMenuItem,animation:true)

}