How to add an icon to a UIActionSheet button?

I hope to learn how to add an icon to a UIActionSheet button?

I checked some document but did not get the result.

Welcome any comment

thank

Interdev

+3
source share
2 answers

It is not possible to do this using the current SDK.

+2
source

Although the API is missing, this is a simple property that you can change.

You can access each UIButton image as follows:

SEL buttonsSEL = @selector(buttons);
if([yourUIActionSheet respondsToSelector:buttonsSEL]) {
    NSString *buttonsSel = NSStringFromSelector(buttonsSEL);

    [[[yourUIActionSheet valueForKey:buttonsSel objectAtIndex:yourIndex]
        setImage:[UIImage imageNamed:@"yourImage.png"]
        forState:UIControlStateNormal];
    ...
}

Where

  • yourUIActionSheet is a UIActionSheet * table
  • yourIndex is an int representing the index of the button, starting at 0
+4
source

Source: https://habr.com/ru/post/1764699/


All Articles