iosswiftuinavigationbareventkitekevent

EKEventEditViewController Add and Cancel buttons are missing but clickable


I'm popping up the EKEventEditViewController and the Add and Cancel buttons seem like they are there - just maybe invisible or white font or something.

The bar button item text is white for the rest of the app, which goes well on the dark blue background I set for the navigation bar.

What's the fix for this?

Here's the code. It's very simple.

let event = EKEvent(eventStore: eventStore)
event.title = myEvent.title
event.startDate = myEvent.dateTimeFrom

event.location = myEvent.addressFormatted()

// All day or not
if( myEvent.isAllDay() ) {
    event.isAllDay = true
}
else {
    event.endDate = myEvent.dateTimeTo
}

let eventController = EKEventEditViewController()
eventController.event = event
eventController.eventStore = eventStore
eventController.editViewDelegate = self
self.present(eventController, animated: true, completion: nil)

Here is how it looks: enter image description here


Solution

  • Just in case anyone needs this, for whatever reason the add / cancel buttons are white (switch to dark mode and you'll see them).

    To fix, right after you set up your EKEventViewController you can mess with UINavigationBar.appearance() properties which will be applied when you present your calendar.

    //Nav bar background
    UINavigationBar.appearance().backgroundColor = .red
    // add + cancel text color
    UINavigationBar.appearance().tintColor = .white
    // title text color
    UINavigationBar.appearance().titleTextAttributes = [.foregroundColor : UIColor.blue]