1

I searched for a way to do this but found no answers! I can change the background color of the buttons, but not the arrow color.

So far I've done this:

let alert: UIAlertController    = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
alert.view.tintColor            = themeTextColor
alert.view.backgroundColor      = themeDialog

I've also tried this:

alert.popoverPresentationController?.backgroundColor = themeDialog

but it doesn't change anything.

The result looks like this:

enter image description here

See the white areas?

Danf
  • 1,409
  • 2
  • 21
  • 39

3 Answers3

1

Change the background color of your presentationController to your desired color.

    public static func newInstance(_ sourceView: UIView) -> PlayerOptionsPopupViewController {
        let controller = PlayerOptionsPopupViewController()
        controller.modalTransitionStyle = .crossDissolve
        controller.modalPresentationStyle = .popover
        if let presentationController = controller.popoverPresentationController {
                presentationController.delegate = controller
                presentationController.permittedArrowDirections = arrowDirection
                presentationController.sourceView = sourceView
                presentationController.sourceRect = sourceView.bounds
                presentationController.backgroundColor = UIColor.bsBalloon // Your Color Here

         }
        return controller
    }
jobernas
  • 686
  • 1
  • 12
  • 24
0

you can change alert view controller colour after presenting it. You are going right in somewhere, but you need to write following code.

self.present(alert, animated: true, completion: {
       alert.view.tintColor = UIColor.red
       alert.view.backgroundColor = .green
})

tintColor will change color of action button and background color will change background of alert view.

I hope this will work for you.

Sagar Chauhan
  • 5,715
  • 2
  • 22
  • 56
-1

In the presenting view controller, try this…

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

    if let popoverPresentationController = segue.destination.popoverPresentationController {
        popoverPresentationController.backgroundColor = themeDialog
    }
}
Ashley Mills
  • 50,474
  • 16
  • 129
  • 160