Here is some code that adds a green check mark image to an action sheet, centered and with same spacing as the default action sheet. The image is pure decoration - it does not respond to user touches. The code is specific to my application so you will need to adapt it as necessary.
In some method that initiates the display of the action sheet (I'm triggering off of an NSNotification but it could be any method):
Code:
- (void)notifyShowSuccessActionSheet:(NSNotification *) notification {
NSLog(@"In ETITMainViewController notifyShowSuccessActionSheet\n");
UIActionSheet *successActionSheet = [[[UIActionSheet alloc] initWithTitle:nil
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:@"Do More", @"Done", @"Another Test?", @"Yet Another", nil] autorelease];
[successActionSheet setOpaque:NO];
[successActionSheet setAlpha:0.8];
[successActionSheet showFromToolbar:[[self naviController] toolbar]];
}
...and in willPresentActionSheet:
Code:
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
UIImageView* successImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CheckMark64.png"]];
NSInteger itemPadding;
NSInteger topPadding = [[[actionSheet subviews] objectAtIndex:0] frame].origin.y;
if ([[actionSheet subviews] count] > 1) {
itemPadding = [[[actionSheet subviews] objectAtIndex:1] frame].origin.y
- ([[[actionSheet subviews] objectAtIndex:0] frame].origin.y
+ [[[actionSheet subviews] objectAtIndex:0] frame].size.height);
}
else {
itemPadding = [[[actionSheet subviews] objectAtIndex:0] frame].size.height / 4;
}
// resize action sheet frame to make space for image
[actionSheet setFrame:CGRectMake([actionSheet frame].origin.x,
[actionSheet frame].origin.y,
[actionSheet frame].size.width,
[actionSheet frame].size.height + [successImageView frame].size.height + itemPadding)];
// re-position buttons
for (UIControl *button in [actionSheet subviews]) {
[button setFrame:CGRectMake([button frame].origin.x,
[button frame].origin.y + [successImageView frame].size.height + itemPadding,
[button frame].size.width,
[button frame].size.height)];
}
[successImageView setFrame:CGRectMake(([[actionSheet superview] frame].size.width / 2) - [successImageView frame].size.width / 2,
topPadding,
[successImageView frame].size.width,
[successImageView frame].size.height)];
[actionSheet addSubview:successImageView];
}