Wednesday, May 29, 2013

UIActionSheet actionSheetStyle example in Objective C (iOS).

UIActionSheet actionSheetStyle

The receiver’s presentation style.

@property(nonatomic) UIActionSheetStyle actionSheetStyle

Discussion of [UIActionSheet actionSheetStyle]
This property determines how the action sheet looks when it is presented. For a list of possible values, see the UIActionSheetStyle constants.

UIActionSheet actionSheetStyle example.
appDel.tabBarController.tabBar.hidden = YES;
NSString *controlBar;
if ([[settingsDictionary objectForKey:@"Task Control Bar"] isEqualToString:@"Hidden"]) {
    controlBar = @"Show Task Control Bar";
} else {
    controlBar = @"Hide Task Control Bar";

UIActionSheet *editActionSheet = [[UIActionSheet alloc] initWithTitle:@"What do you like to do?"
                                               destructiveButtonTitle:@"Delete All Tasks"
                                                    otherButtonTitles:@"Arrange Task List", @"Mark All as Done", controlBar, nil];

editActionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
[editActionSheet showInView:self.tableView];
appDel.tabBarController.tabBar.hidden = NO;
[editActionSheet release];

Example of [UIActionSheet actionSheetStyle].
#import "QuartzCore/QuartzCore.h"

yourActionSheet.delegate = self;
yourActionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
    [[actionSheet layer] setBackgroundColor:[UIColor redColor].CGColor];

UIActionSheet actionSheetStyle example.
- (void)manualAddModel
    UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle: @"Select Equipment Type"
                                                            delegate: self
                                                   cancelButtonTitle: @"Cancel"
                                              destructiveButtonTitle: nil
                                                   otherButtonTitles: @"Add Boiler", @"Add Furnace",  nil];

    popupQuery.actionSheetStyle = UIActionSheetStyleDefault;
    [popupQuery addButtonWithTitle:@"Cancel"];
    [popupQuery showInView:self.view];

End of UIActionSheet actionSheetStyle example article.