Ahmad Kayyali Ahmad Kayyali - 3 months ago 35
Objective-C Question

Adding Images to UIActionSheet buttons as in UIDocumentInteractionController

Is it possible to add an image to the buttons of the

UIActionSheet
as seen in
UIDocumentInteractionController
? If so, please let me know how it is done.


Answer

Try this way, i hope it may be help you.

UIActionSheet * action = [[UIActionSheet alloc] 
                      initWithTitle:@"Title" 
                      delegate:self 
                      cancelButtonTitle:@"Cancel" 
                      destructiveButtonTitle:nil 
                      otherButtonTitles:@"",nil];

[[[action valueForKey:@"_buttons"] objectAtIndex:0] setImage:[UIImage imageNamed:@"yourImage.png"] forState:UIControlStateNormal];

[[[action valueForKey:@"_buttons"] objectAtIndex:0] setImage:[UIImage imageNamed:@"yourImage_Highlighted.png"] forState:UIControlStateHighlighted];
Comments