iOS Code Snippet Setting a button's image/icon

Based on:
https://stackoverflow.com/questions/36301791/how-to-set-the-icon-on-the-button-in-ios-using-swift

Usage (tested with myButton as Button, myImage as B4XBitmap):
B4X:
Dim no As NativeObject = Me
no.RunMethod("setButtonIcon:::", Array(myButton, myImage, no.MakeEdgeInsets(0, 0, 8, 0)))

Code:
B4X:
#IF OBJC
- (void)setButtonIcon: (UIButton*)button :(UIImage*)icon :(UIEdgeInsets)edgeInsets
{
    [button setImage:icon forState:UIControlStateNormal];
    [[button imageView] setContentMode: UIViewContentModeScaleAspectFit];
    [button setImageEdgeInsets: edgeInsets];
}
#END IF
 
Top