它尝试了以下代码段来使用我自己的按钮自定义后退栏按钮。这没有效果,因为它看起来像默认的后退按钮。
EKEventViewController*eventView = [[EKEventViewController alloc] initWithNibName:nil bundle:nil];
eventView.event = closestEvent;
eventView.allowsEditing = NO;
UIButton* leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
[leftButton setImage:[UIImage imageNamed:@"closeButton.png"] forState:UIControlStateNormal];
leftButton.frame = CGRectMake(0, 0, 25, 25);
[leftButton addTarget:nil action:nil forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
[self.navigationController pushViewController:eventView animated:YES];
我还尝试将 EKEventViewController 作为另一个视图控制器的子视图,我不知道如何正确处理它。无论哪种方式,我只想自定义后退按钮。
更新,我试过这个:
eventView.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
可以工作,但随后会在右侧自动添加一个完成按钮(可能是在运行时?)我试图将右栏按钮归零但没有效果:
eventView.navigationItem.rightBarButtonItem = nil;