title: Remove Subview of UIButton
body: <p>im running the same piece of code over and over when the user presses a button. If the user presses the button an image appears over the button, if they press it again the image is removed from the buttons subview.</p>
  
  <p>here is my code:</p>
  
  <pre><code> UIImageView *overlay = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"OverlayImage.png"]];
  
      NSString *senderstag = [NSString stringWithFormat:@"%i", buttonFromSender.tag];
      if([[dictonaryOfImagesToDelete allKeys] containsObject:senderstag]){
          [[buttonFromSender subviews]makeObjectsPerformSelector:@selector(removeFromSuperview)]; 
      }
      else{
      [buttonFromSender addSubview:overlay];
      }
      NSString *imageName = [[NSString alloc]init];
      imageName = [arrayWithImageNames objectAtIndex:buttonFromSender.tag];
  
      [imagesToDelete addObject:imageName];
  
      [dictonaryOfImagesToDelete setObject:imagesToDelete forKey:[NSString stringWithFormat:@"%i", buttonFromSender.tag]];
  </code></pre>
  
  <p>Im using a dictionary to keep track of which buttons have been pressed. instead of the imageview over the button being removed, it removes the whole button. How can i get it just to remove the imageview and not the button?</p>
  
  <p>Thanks :D</p>