开发者

how to add an icon to an UIActionSheet button?

开发者 https://www.devze.com 2023-01-16 06:43 出处:网络
I hope to know how to add an icon to an UIActionSheet button? I checked some documen开发者_如何学运维t but no result.

I hope to know how to add an icon to an UIActionSheet button?

I checked some documen开发者_如何学运维t but no result.

Welcome any comment

Thanks

interdev


Although there is no API, it is a simple property you can change.

You can access each UIButton image like so:

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*
  • yourIndex is an int representing the button index, starting at 0


No way to do this with the current SDK.

0

精彩评论

暂无评论...
验证码 换一张
取 消