iphone - Set UIImageView background color upon user intervention -


i developing application in have horizontal scroller. scroller area comprise of different colors [which nothing uiimageview of colors].

above scroller area canvas [which uiimageview].

now, want when select color in scroller area, should set on canvas.

it pretty color picker providing solid color options selected user.

how should go ? sample code me started or mind kicking awesome ?

thanx ton

can take uibuttons instead of uiimageviews inside scrollview show colours picked.

this make implementation easier. user select colour button , receive callback in buttons action selector method. based on button tag or property can set colour canvas.

in current implementation tricky need know exact content offset tap done make out uiimageview pressed.

coding steps:

  • in scroll view add uibuttons instead of uiimageview like:

    uibutton* button = [[uibutton alloc] initwithframe:somerect]; //put tag button  button.tag = someint; //add selector each button callback [view addtarget:self action:@selector(btnselected:) forcontrolevents:uicontroleventtouchupinside]; [scrollview addsubview:button]; 
  • in btnselected method put code:

    -(ibaction)btnselected:(id)sender; {   uibutton* button = (uibutton*) sender;    if (button.tag == someint) {     //do     canvas.backgroundcolor = button.backgroundcolor;   } } 

Comments