0

By default, a UIAlertView with two buttons has different alpha for each button.

Is there a way to make them look identical with different text, without subclassing UIAlertView, or making a custom alert view?

Here is what i used:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:  
                     kAlertTitleOrderType message:kAlertMessageOrderType delegate:delegate
                     cancelButtonTitle:nil otherButtonTitles:@"Collection", @"Delivery", nil];

enter image description here

bursyllac
  • 413
  • 1
  • 5
  • 11
  • 1
    I nuked my answer as it turned out to be wrong. See http://stackoverflow.com/questions/7250360/uialertview-without-cancel-button for more. It looks like you might have to roll your own! Interestingly, this behaviour is "fixed" in iOS 7 (i.e. cancel buttons are optional, and if you don't have them, all the buttons render identically), so it might be a bug. – Adam Wright Jul 25 '13 at 13:21
  • Thanks. Indeed, it seems I have to use a custom alertView. – bursyllac Jul 25 '13 at 13:37

1 Answers1

0

If you set the cancel button to nil when calling initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles: then no cancel button will be added (this is the one that looks different). You can then add other buttons as you require.

Wain
  • 118,658
  • 15
  • 128
  • 151
  • Doesn't work. Here is my line: UIAlertView *alert = [[UIAlertView alloc] initWithTitle: kAlertTitleOrderType message:kAlertMessageOrderType delegate:delegate cancelButtonTitle:nil otherButtonTitles:@"Collection", @"Delivery", nil]; – bursyllac Jul 25 '13 at 11:57
  • Can you provide a screen shot of the result you see on screen? – Wain Jul 25 '13 at 12:01
  • I just uploaded the screenshot. – bursyllac Jul 25 '13 at 12:04
  • Check the value of `cancelButtonIndex`. If it's `0`, set it to `-1`. If it's `-1`, I guess you'll need to subclass / tamper with subviews / use a custom view. – Wain Jul 25 '13 at 12:16