我想使用会有一些图像的自定义 barbutton。我正在按照以下代码进行操作。但是 barbutton 没有显示。
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"icon.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(nowPlayingButtonClicked) forControlEvents:UIControlEventTouchUpInside];
nowPlaying = [[UIBarButtonItem alloc] initWithCustomView:button];
nowPlaying.action = @selector(nowPlayingButtonClicked);
nowPlaying.target = self;
self.navigationItem.rightBarButtonItem = nowPlaying;