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