我们可以修改EKEventEditViewController的“取消”和“完成”项目以在iphone应用程序中自定义

时间:2014-06-05 11:08:17

标签: ios7 eventkit

如果有人成功修改了这些项目,我需要帮助修改导航栏中取消和完成的UI,大写“CANCEL”和“DONE”以及iphone应用程序中的自定义字体。

1 个答案:

答案 0 :(得分:0)

只需将下面的代码复制并粘贴到您通过其呈现EKEventEditController的ViewController中。

#pragma mark - Cancel/Done Events
-(void)cancelDidTapped:(UIBarButtonItem*)eventSender
{
   NSLog(@"left Click");
   [self dismissViewControllerAnimated:TRUE completion:nil];
}
-(void)doneDidTapped:(UIBarButtonItem*)eventSender
{
   NSLog(@"right Click");
   [self dismissViewControllerAnimated:TRUE completion:nil];
}
#pragma mark - Extra
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    [viewController.navigationItem setLeftBarButtonItem:nil animated:NO];
    [viewController.navigationItem setRightBarButtonItem:nil animated:NO];

    UIBarButtonItem *btnCancel = [[UIBarButtonItem alloc]initWithTitle:[@"cancel" uppercaseString] style:UIBarButtonItemStyleBordered target:self action:@selector(cancelDidTapped:)];

    UIBarButtonItem *btnDone = [[UIBarButtonItem alloc]initWithTitle:[@"done" uppercaseString] style:UIBarButtonItemStyleBordered target:self action:@selector(doneDidTapped:)];


    [viewController.navigationItem setLeftBarButtonItem:btnCancel];
    [viewController.navigationItem setLeftBarButtonItem:btnDone];
    [viewController.navigationItem setTitle:@"Testing"];

}

除此之外,还将EKEventEditController委托设置为self。

EKEventEditViewController *addController = [[EKEventEditViewController alloc] init];
addController.delegate = self;

你很高兴去,欢呼!