开发者

What is the easiest way to make a UIAlertView that's tinted of a different color?

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 a开发者_运维百科nd claims the OP shouldn't do it.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜