有些时候,我们需要将leftBarButtonItem使用图片代替文字如“菜单”按钮,可以使用如下代码即可实现
UIButton *TastoVersamento = [UIButton buttonWithType:UIButtonTypeCustom];
[TastoVersamento setImage:[UIImage imageNamed:@"ICON_menu"] forState:UIControlStateNormal];
[TastoVersamento addTarget:self action:@selector(showMenu:) forControlEvents:UIControlEventTouchUpInside];
[TastoVersamento setFrame:CGRectMake(0, 0, 40, 40)];viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:TastoVersamento];