Select to view content in your preferred language

Editing Navigation Bar In AGSPopupsViewController

293
0
12-15-2021 02:26 PM
ThomasKellough
Emerging Contributor

Using AGSPopupsViewController does not fully support dark mode at the moment, so I'm trying to override a couple of values to help this. 

Here is how I'm presenting my popups view controller:

self.popupsViewController = AGSPopupsViewController(popups: result.popups, containerStyle: .navigationBar)
self.popupsViewController.modalPresentationStyle = .formSheet
self.popupsViewController.delegate = self
self.present(self.popupsViewController, animated: true)

This launches just fine, except in dark mode the "Done" and Edit" buttons are both black while the background is also black. In light mode everything looks fine. 

 

I've tried a couple of things. 

self?.popupsViewController.doneButton?.setTitleTextAttributes([
    NSAttributedString.Key.foregroundColor: UIColor.purple], for: .normal
)
self?.popupsViewController.actionButton?.setTitleTextAttributes([
    NSAttributedString.Key.foregroundColor: UIColor.orange], for: .normal
)

The above approach has two a couple of problems. The doneButton color change works just fine, however, the actionButton is nil. So I'm not sure how to get access to the UIBarButtonItem that is the 'Edit' button. Second, when you are in edit mode, the 'Cancel' and 'Done' buttons go back to being black at all times. I'm not sure how to access these either.

I've also tried editing the customDoneButton and customActionButton property, but pretty much functions the same as above, except I now need to set specific methods instead of using the built-in delegate methods.

 

I've tried overriding the background color

self.popupsViewController.view.backgroundColor = .white

 This helps a bit. The main modal still has more views over it so it respects dark mode, while the navigation bar turns to grey. It makes it a little bit easier to read the black text in the navigation bar, but still not clear enough.

I've tried editing the navigation bar directly, but I'm unsure how to get access to it. 

self.popupsViewController.navigationController // returns nil so any edits after do nothing

self.popupsViewController.popups?.first! // returns a popup (thinking maybe the navigation bar was on that), but I don't have access to the navigation bar there

 

Is there any way to fully support dark mode in the AGSPopupViewController? Or will I need to create an entirely new view myself to support this?

0 Kudos
0 Replies