Aug 19, 2010

(iPhone)How to customize UIAlertView

First solution is using addSubview which add subviews into an UIAlertView, just don't forget add newlines in the initWithTitle method's message to make sure you have enough space for subviews. Like :

[[UIAlertView alloc] initWithTitle:@"Title" message:@"\n\n\n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil]

But this solution couldn't change UIAlertView's background, here is second solution that creates an UIAlertView's subclass, overrides several methods (setAlertText, alertText, drawRect, layoutSubviews and show), Joris Kluivers made an excellent sample, check it here : CustomAlert 

No comments: