Jonas Stawski
Jonas Stawski

Reputation: 6752

What's the supported way of customizing the UIAlertView?

I need to display a UIAlertView to display messages, but I need to change the background colors and textcolors. Is this possible? If so, what is the supported and recommended way of doing so?

Upvotes: 1

Views: 217

Answers (1)

poupou
poupou

Reputation: 43543

There's no supported way beside the exposed properties of UIAlertView and its delegate: UIAlertViewDelegate (pretty limited).

This is likely the point that the other links (in the comments) wants to make - i.e. the hacks that worked in earlier iOS releases do not work anymore. You can adapt them - but it's likely to break again. Here's the official words from Apple documentation:

Subclassing Notes

The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.

In reality a lot of applications do subclass UIAlertView and the same tricks will also work with MonoTouch (at least as well as they would from Objective-C) but it's not supported and it will breaks/need adjustments between iOS releases. I won't recommend it but playing with the hierarchy is likely the only option (beside building your own).

Upvotes: 1

Related Questions