views:

39

answers:

1

I have a horizontal UIScrollView. It have 3 pages. It I have 3 UIButtons on each page of the scrollview. Total of 9 UIButtons. I need to set a different color when a button is touched, so that I can differentiate that touched button with the other buttons.

I tried setColor by checking BOOL values. It is working for single page. When I touch a button it's color is changed and I can remove the color for other buttons in same page. But, the color set in other page is still there.

How can I set the other button colors (of other pages) to nil when I touch on any button in any page.

A: 

You need to keep references to the UIButton objects that are being added as subviews of the other UIScrollView pages. If you have references to all nine button objects from the view controller (containing the UIScrollView) then you will be able to arbitrarily set their state from the touch handlers for the nine buttons.

Cannonade
@Cannonade, I am keeping he references of all the nine buttons. I am able to call different methods for all the nine buttons. In that method I am setting the values(colors) of the buttons. But, I could not get the solution.
srikanth rongali
@srikanth-rongali Are you trying to set the background color on a UIButtonTypeRoundedRect type button? Unfortunately that won't work. Check out this post for details on setting button background colors: http://www.cimgf.com/2010/01/28/fun-with-uibuttons-and-core-animation-layers/
Cannonade
@@srikanth-rongali If there is anything I can add here. Let me know.
Cannonade