Adding Images to UIActionSheet buttons as in UIDocumentInteractionController

后端 未结 12 1620
我寻月下人不归
我寻月下人不归 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 19:58

    I know it's very late answer, but I found another way to show image in action sheet:

    self.actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Image:" delegate:self cancelButtonTitle:@"Cancel"destructiveButtonTitle:nil otherButtonTitles: @"Image1", @"Image2", @"Image3", @"Image4", @"Image5", @"Image6", @"Image7", @"Image8",@"Image9", @"Image10", @"Image11", @"Image12", @"Image13", @"Image14", @"Image15", nil];
    
    self.actionSheet.tag = 1;
    for (id button in [self.actionSheet valueForKey:@"_buttons"])
     {
         UIImageView* buttonImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[button titleForState:UIControlStateNormal]]];
         [buttonImage setFrame:CGRectMake(5, 5,35,35)];
         [button addSubview:buttonImage];
     }
    
     [self.actionSheet showInView:[UIApplication sharedApplication].keyWindow];
    

提交回复
热议问题