我正在创建一个自定义 UINavigationBar BarButtonItem,如下所示:
// Set up bar button items
UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 35.0f, 35.0f)];
[backButton setImage:[UIImage imageNamed:@"myimg.png"] forState:UIControlStateNormal];
[backButton addTarget:self action:@selector(myselector) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
这工作得很好,但是当我去设置 UIButton 或 BarButtonItem 的标题时,它不会显示出来。有什么建议么?
试过...
[backButton setTitle:@"Edit" forState:UIControlStateNormal];
[backButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
和...
self.navigationItem.leftBarButtonItem.title = @"Edit";
没有运气。