In my app the user can create many UIImageViews programmly, and tags are assigned successfully to all the ImageViews. Then, in the following way I detect (in this case through touches moved) the tag of the image, and according to the tag I change the color.
int touchedtag = touch.view.tag;
NSUInteger tagCount = touchedtag;
switch (tagCount) {
case 1:
image1.backgroundColor = [UIColor redColor];
break;
case 2:
image1.backgroundColor = [UIColor yellowColor];
break;
case 3:
image1.backgroundColor = [UIColor brownColor];
break;
case 4:
image1.backgroundColor = [UIColor blackColor];
break;
default :
break;
}
as you can see there are 4 cases. But if the user creates 50 UIImageViews, do I need to create 50 cases, or it’s possible to do this identification process with less code?? (CONSIDER THAT THE CHANGE OF COLOR IS TO SEE IF IT WORKS, BUT THEN THIS WILL BE ONLY USED TO IDENTIFY THE TAG)
For the 50 different
UIImageViewTag you can also programable define your tag.And switch case them with their tag
For the 50 different color , you can customize the color to
UIImageViewwith RGB parameter like thisTry to use
forloop to programmable adjust these parameter such increase red 2 unit or decrease blue 10 unit for each imageHope it helps you !