I'm trying to get the name of the background image from a custom button.
I call this method when I click over the UIButton:
-(void)getButtonImageName:(id)sender{
UIButton *resultButton = (UIButton *)sender;
NSLog(@" The button's image is %@.", resultButton.currentImage);
}
I can get the title and other properties from the button but not the background image name.
Anyone know how to do that? Thanks!
This is the simplest approach to get the current image of a custom button
-(void)yesButtonButtonCliked:(id)sender
{
UIButton *tmpYes = (UIButton *)sender;
[self ClearAllButtons:tmpYes.tag:@"YES"];
UIImage* selectedImg=[UIImage imageNamed:@"checkboxtick.png"];
if (tmpYes.currentImage == selectedImg )
{
}
else
{
[tmpYes setImage:[UIImage imageNamed:@"checkboxtick.png"] forState:UIControlStateNormal];
}
NSLog(@"Button tag is %d",tmpYes.tag);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With