1
我從UIButton
自定義了UIBarButtonItem
。自定義欄按鈕是可見的,動作有效,大小正確,並且可以看到背景色;然而手動設置的標題不能被看到。也許背景是放置在文字上?我不確定,幫忙?來自UIButton的自定義UIBarButtonItem的標題不顯示
在viewDidLoad
:
UIButton *resetButton = [UIButton buttonWithType:UIButtonTypeCustom];
resetButton.frame = CGRectMake(0, 0, 65, 30);
[resetButton addTarget:self action:@selector(speakPhrase:) forControlEvents:UIControlEventTouchUpInside];
resetButton.titleLabel.font = [UIFont fontWithName:@"ProximaNova-Bold" size:19];
resetButton.titleLabel.text = @"RESET";
resetButton.titleLabel.textColor = [UIColor whiteColor];
resetButton.backgroundColor = [UIColor redColor];
resetButton.showsTouchWhenHighlighted = YES;
UIBarButtonItem *resetBarBTN = [[UIBarButtonItem alloc] initWithCustomView:resetButton];
self.navigationItem.rightBarButtonItem = resetBarBTN;
它的工作取代你的代碼,謝謝! – momodude22