How to change the image on the button that I created in the Xcode interface builder?

Using xcode, I created an interface with several buttons, the problem I am facing is that I would like to change the image to a button after clicking. I understand how to do this if I create a button programmatically, but I don’t know how to change the image created in the interface builder.

I don't want to start from scratch and re-create the interface programmatically, so if anyone could point me in the right direction, I would appreciate it.

Thanks.

+4
source share
2 answers

Use the button image property:

@property(nonatomic, readonly, retain) UIImage *currentImage 

You need to establish an IBOutlet connection with UIButton .

+1
source

Make sure your class has the corresponding UIButton property for the button:

 @property(nonatomic, strong) IBOutlet UIButton *m_Button; 

Then, in the user interface builder, you can connect the button and the outlet. In your code, you can access the properties of the buttons that you created programmatically.

+1
source

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


All Articles