Just select and start a new instance of UIActionSheet and add buttons one by one using –addButtonWithTitle: This method returns you the index into which the button was added. You can then set the index of the destructive button through -setDestructiveButtonIndex.
Here is an example that adds one button and adds another if the boolean value of useDestructiveButton is YES (and directly sets it as a destructive button, making it red):
UIActionSheet *sheet = [[UIActionSheet alloc] init]; [sheet addButtonWithTitle:@"Button 1"]; if (useDestructiveButton) { [sheet setDestructiveButtonIndex:[sheet addButtonWithTitle:@"Button 2"]]; }
Remember to call the appropriate show method.
source share