Adding Images to UIActionSheet buttons as in UIDocumentInteractionController

后端 未结 12 1597
我寻月下人不归
我寻月下人不归 2020-11-30 19:39

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

12条回答
  •  情深已故
    2020-11-30 20:09

    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];
    

提交回复
热议问题