在storyboard上set image会显示成蓝色的形状,查过资料说应该设置图片的alpha值,还TND设置个鬼的alpha,从stackOverFlow找到了解决方法,很简单,具体思路是:
1. 构建一个带背景的UIButton
2. 把构建的UIButton用UIBarButton初始化
具体代码:
//设置UIButton
UIImage *menuImage = [UIImage imageNamed:@"navBarMenuButton.png"];
UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
leftButton.frame = CGRectMake(0, 0, menuImage.size.width, menuImage.size.height);
[leftButton setBackgroundImage:menuImage forState:UIControlStateNormal];
//以UIBarButton初始化
aController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];