Wednesday, May 29, 2013

UIActionSheet UIActionSheetStyleBlackTranslucent example in Objective C (iOS).

UIActionSheet UIActionSheetStyleBlackTranslucent

Specifies the style of an action sheet.

typedef enum {
UIActionSheetStyleAutomatic = -1,
UIActionSheetStyleDefault = UIBarStyleDefault,
UIActionSheetStyleBlackTranslucent = UIBarStyleBlackTranslucent,
UIActionSheetStyleBlackOpaque = UIBarStyleBlackOpaque,
} UIActionSheetStyle;

Constants
UIActionSheetStyleAutomatic
Takes the appearance of the bottom bar if specified; otherwise, same as UIActionSheetStyleDefault.
UIActionSheetStyleDefault
The default style.
UIActionSheetStyleBlackTranslucent
A black translucent style.
UIActionSheetStyleBlackOpaque
A black opaque style.

UIActionSheet UIActionSheetStyleBlackTranslucent example.
        if (existsInInvitedList) {
            eventUserInvitedSheet = [[UIActionSheet alloc] initWithTitle:eventObject.name delegate:self
                                                       cancelButtonTitle:@"Cancel"
                                                  destructiveButtonTitle:nil
                                                       otherButtonTitles:@"Join", @"Decline", @"Chat creator", nil];
            eventUserInvitedSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
            [eventUserInvitedSheet showFromTabBar:self.tabBarController.tabBar];
        }else if (existsInAcceptedList){
            eventUserAcceptedSheet = [[UIActionSheet alloc] initWithTitle:eventObject.name delegate:self
                                                        cancelButtonTitle:@"Cancel"
                                                   destructiveButtonTitle:nil
                                                        otherButtonTitles:@"Revoke invite", @"Chat creator", nil];
            eventUserAcceptedSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
            [eventUserAcceptedSheet showFromTabBar:self.tabBarController.tabBar];
        }

Example of [UIActionSheet UIActionSheetStyleBlackTranslucent].
UIActionSheet *actionSheet = [[UIActionSheet alloc] init];
  actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
  actionSheet.title = @"some text";//here type your information text
  actionSheet.delegate = self;

  [actionSheet addButtonWithTitle:@"Button 1"];
  [actionSheet addButtonWithTitle:@"Button 2"];
  [actionSheet setCancelButtonIndex:1];

//it is up to you how you show it, I like the tabbar
  [actionSheet showFromTabBar:self.tabBarController.tabBar];

//here lays the trick - you change the size after you've called show
  [actionSheet setBounds:CGRectMake(0,0,320, 480)];

//now create and add your image
   UIImageView *subView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"exampleimage.png"]];
   subView.ContentMode = UIViewContentModeScaleAspectFit;
   subView.Frame = CGRectMake(0,130,320,180);//adjust these, so that your text fits in
   [actionSheet addSubview: (subView)];
   [subView release];

  [actionSheet release];    

UIActionSheet UIActionSheetStyleBlackTranslucent example.
-(void)ctnPhotoSelection
{
    isMyCtView = YES;
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@""
                                                             delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil
                                                    otherButtonTitles:@"Take Photo With Camera", @"Select Photo From Library", @"Cancel", nil];
    actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
    actionSheet.destructiveButtonIndex = 1;
    [actionSheet showInView:self.view];
    [actionSheet release];
}

End of UIActionSheet UIActionSheetStyleBlackTranslucent example article.