1

I am using monotouch but will accept Objective-C answers.

I'd like a visual indication of whether or not a UIAlertView message is important or not.

I found an Objective-C example of how to show an icon in the alert (somewhere here on stackoverflow) but the text does not wrap around the icon.

Perhaps there is another alternative. Maybe there is a way to change the background color of the alert to yellow?

So my specific question is whether or not there is a standard practice for this or can someone recommend a good solution?

Thanks

John
  • 513
  • 1
  • 6
  • 11
  • 1
    A UIAlertView is meant to inform the user of an important event. Consider a different way to inform your users of non-important events so that when an alert view is presented it isn't taken lightly. – Mick MacCallum May 13 '12 at 04:30

2 Answers2

2

Apple's HIG emphatically suggests that the appearance of an AlertView should be coordinated with the color scheme of the background. The only visual indication that they suggest is the use of the red button for potentially destructive actions. I agree with @MDT that all alerts should be, by definition, important, and non-important messages (e.g. routine status messages), should be presented in some other manner.

Rob
  • 415,655
  • 72
  • 787
  • 1,044
  • Each notification/message has 2 different (yet similar) attributes: importance and whether or not the user must click ok before the message disappears. With Android I was able to implement this somewhat using statusbar notifications and popup alerts. But it doesn't look like I can add iOS notifications without using push notifications? I did find a Toast like alert class for normal importance messages here: http://stackoverflow.com/questions/4221169/android-toast-in-iphone – John May 13 '12 at 14:51
0

In General people prefer not to customize it much though. Here's some UI Guideline by Apple. Yes you can customize UIAlertView but for that you will have to subClass it and override it's methods :-

@interface CustomAlertView : UIAlertView

@end

in .m file override the method layoutSubviews:-

- (void)layoutSubviews
{
    for (UIView *subview in self.subviews){ //Fast Enumeration
        if ([subview isMemberOfClass:[UIImageView class]]) {
            subview.hidden = YES; //Hide UIImageView Containing Blue Background
        }

        if ([subview isMemberOfClass:[UILabel class]]) { //Point to UILabels To Change Text
            UILabel *label = (UILabel*)subview; //Cast From UIView to UILabel
            label.textColor = [UIColor colorWithRed:210.0f/255.0f green:210.0f/255.0f blue:210.0f/255.0f alpha:1.0f];
            label.shadowColor = [UIColor blackColor];
            label.shadowOffset = CGSizeMake(0.0f, 1.0f);
        }
    }
}

and then you will have to override drawRect , You can see this tutorial on CustomAlert if you want totally different Alert.

Abhishek Singh
  • 6,068
  • 1
  • 23
  • 25