|Jul 25, 2008, 03:37 PM||#1|
iPhone SDK: anybody has a clue why UIButton.highlighted does not seems to work ?
i have been trying to use ordinary round rect buttons to spare resources
i guess a standard button is easier on the system than an image based one,
am i wrong ?
i was trying to use them as radio buttons or on off ones,
where by clicking on a button it will get highlighted to indicate status
however, although i can set the highlighed state of any other button,
it does not work with the button that is being pressed,
after unpressing it always gets back to non highlighted state
is there a workaround ?
also i cannot seem to find a way to colour a UIButton,
it allows setting text color, background color, shadow but no button color
anybody has a suggestion ?
is there any way to achieve this or do i need to use image based buttons ?
thanks in advance for your help
|Aug 10, 2008, 01:46 PM||#2|
I assume that you simply want them to appear as though they are highlighted when you have selected them? Essentially making them act like radio buttons, correct? If that is the case then I have a solution for you. It's just a few lines of code in your applicationDidFinishLaunhing method, and then you have to set the state of each button in it's target method, but that's easy enough.
Use this image as your UIButton's backgroundImage:
In your applicationDidFinishLaunching Method, add these lines (assuming three buttons):
//Sets the background images and title colors of the buttons to appear "highlighted" when they are selected [UIButton1 setBackgroundImage:[UIImage imageNamed:@"ButtonBack.png"] forState:UIControlStateSelected]; [UIButton2 setBackgroundImage:[UIImage imageNamed:@"ButtonBack.png"] forState:UIControlStateSelected]; [UIButton3 setBackgroundImage:[UIImage imageNamed:@"ButtonBack.png"] forState:UIControlStateSelected]; [UIButton1 setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected]; [UIButton2 setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected]; [UIButton3 setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
Hope that helps.
Yo' mama's so STUPID, she went to Bangkok to get a TIE Fighter.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|Bumper with skins just does not seem to work well||Uabcar||iPhone Accessories||6||Jul 6, 2010 02:08 PM|
|"clear" does not seem to work in SL||mnpmac||OS X||7||Sep 28, 2009 02:57 AM|
|Extending Monitor does not seem to work||cwrighta70||Windows, Linux & Others on the Mac||4||Jul 28, 2009 12:47 PM|
|Sleep function under 64-bit Vista Ultimate does not seem to work||hajime||Windows, Linux & Others on the Mac||0||Jul 27, 2008 09:42 PM|
|WiFi Encryption Does Not Seem to Work||infosprt||iPhone Tips, Help and Troubleshooting||12||Jun 30, 2007 03:45 PM|
All times are GMT -5. The time now is 08:53 PM.