我正在用自定義背景圖像和標題創建自定義UINavigationItem。圖像顯示,但標題不顯示。什麼可能是錯的? 我做這樣說:自定義UINavigationItem上的標題未顯示
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"bar_button.png"] forState:UIControlStateNormal];
[button setBackgroundImage:[UIImage imageNamed:@"bar_button_black.png"] forState:UIControlStateSelected];
[button setBackgroundImage:[UIImage imageNamed:@"bar_button_black.png"] forState:UIControlStateHighlighted];
[button setTitle:@"Cancel" forState:UIControlStateNormal];
[button setTitle:@"Cancel" forState:UIControlStateSelected];
[button setTitle:@"Cancel" forState:UIControlStateHighlighted];
[button addTarget:self action:@selector(closeButtonClicked) forControlEvents:UIControlEventTouchUpInside];
[button setFrame:CGRectMake(0, 0, 49, 30)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
明白了。謝謝! – Misha