Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change UIButton type programmatically

I have an UIButton made with IB, it is set to "Rounded Rect". At one point, I'd like to change the type to "Custom" in the code, is that possible ? I saw the type can be set at creation, but did not see if it was possible to change it later on.

like image 824
Luc Avatar asked Nov 12 '11 20:11

Luc


2 Answers

If I'm not mistaken, different button types are represented by different (private) subclasses of UIButton. That's why you can only set type at creation time but not after.

like image 158
breakp01nt Avatar answered Oct 17 '22 00:10

breakp01nt


I don't know if I'll be much help, but for me it worked by doing:

button = [UIButton buttonWithType:(UIButtonType)];

example:

calculateButton = [UIButton buttonWithType: UIButtonTypeRoundedRect];
like image 3
JomanJi Avatar answered Oct 17 '22 00:10

JomanJi