David Henry
David Henry

Reputation: 3036

Change UIAlertViewController Tint Color

I am using google sign in for my swift application. When the user clicks to sign in the API gives this UIAlert. Is there any way to change the tint colour of this? I.e. the "Cancel" & "Continue"?

UIAlertView

I have even tried to change it globally using AppDelegate code below;

UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = Color.brandPurple

This has no effect.

Upvotes: 3

Views: 759

Answers (2)

Mojtaba Hosseini
Mojtaba Hosseini

Reputation: 119128

You have two options, (And duo to the name of the color you used and method you already tried, probably first option is what you are looking for)

All alerts (and other stuff)

you can change the window's tintColor

it could be accessed from any view

view.window?.tintColor = Color.brandPurple

Just a single alert

Change that single alert's view's tintColor

alertController.view.tintColor = Color.brandPurple

Upvotes: 1

SGDev
SGDev

Reputation: 2252

Just set tintColor of UIAlertController.

 alertController.view.tintColor = Color.brandPurple // alertController is the object of UIAlertController

Upvotes: 5

Related Questions