views:

250

answers:

2

My application uses a black navigation bar and other custom colors for various UI components and the dark-blue tinted alert views look really out of place.

I'd like to make the alert view translucent black without having to resort to using an image file.

I'm not opposed to generating the UIImage, since I get that the only way to change the background is to use a UIImage, but all of my attempts (based on question 1 below) just make a solid black rectangle behind the alert view (the corners aren't rounded.)

Related but not duplicate:

  1. how to change background color of UIAlertView ?
  2. how can I change the color of UIAlartView ?

The first one uses an image "Background.png" in order to set that as the background. The second question links to the first one and claims the OP shouldn't do it.

+5  A: 

The fact that there are no API hooks to do this should be a red flag - you shouldn't do it. It's not using Private APIs (which will get you a rejection), but it's leveraging undocumented behavior, which Apple advises against. In fact, last week at the iPhone tech talk I was specifically warned by an Apple Dev Evangelist to not to do stuff like this because it will break in the future.

If you really want to do your own thing when it comes to UIAlertViews, you should create your own view and present it via a Modal View Controller.

bpapa
Nailed it - this is the way to go now, especially with Apple analyzing the binaries for illicit access to private APIs.
Danilo Campos
A: 

Since the UIAlertView does not allow for changing the background color through any public API, the only way to customize its background color is to subclass UIAlertView.

Ben S