Adding Images to UIActionSheet buttons as in UIDocumentInteractionController

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

    The standard UIActionSheet doesn't support images.

    One way to add an image to the UIActionSheet is to add a subview to the UIActionSheet. Just implement the UIActionSheetDelegate method willPresentActionSheet: like this:

    - (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
         UIImageView* buttonImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"picturename.png"]];
         // Set the frame of the ImageView that it's over the button.
         [actionSheet addSubview:buttonImage];
         [buttonImage release]; // only if you don't need this anymore
    }
    

    I'm not sure if the image responds to touches, but you can build a UIActionSheet like theUIDocumentInteractionController.

提交回复
热议问题