tags:

views:

45

answers:

1

I've got a UIButton that I create at runtime. I put a title on it and have a few states set for it. I DO NOT have an image set to the background and want to avoid this. So the button should simply be a custom button with text in the middle.

When I click on it I see 0 feedback that I clicked on it. I can set the text to change states, but I don't get that grey highlighted color on top.

I've tried:

[button setShowsTouchWhenHighlighted:YES];

And get nothing. again I can set the title color to chagne based on the state but thats not really what I'm looking for. Any Ideas?

Thanks for any and all help.

A: 

change button type as: UIButtonTypeRoundedRect instead of UIButtonTypeCustom


UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; myButton.frame = CGRectMake(20, 20, 200, 44); // position in the parent view and set the size of the button [myButton setTitle:@"Click Me!" forState:UIControlStateNormal]; // add targets and actions [myButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; // add to a view [superView addSubview:myButton];

iPhoneDev
how would you set this property? I get Object cannot be set - either readonly or no setter found?
David Nelson
see the edited code
iPhoneDev
This will work but then requires me to change my extended button class type. This can be worked around.A better solution is to just use a blank .png image and set a title screen. I used a plain white image with black text.. works perfectly.
David Nelson