I’m using a UIButton as a pressable imageView. Right now when I press the button the background image is still visible but a gray, transparent layer is on top of the image. How do I change the color of this layer?
I’ve tried setting the setBackgroundImage:forState: but all that does is replace the current image with another image.
Note
I’m able to do this with a tableview row using the following code:
// Custom selectionStyle color
UIView *v = [[[UIView alloc] init] autorelease];
v.backgroundColor = [UIColor myBlue];
groupCell.selectedBackgroundView = v;
Apple’s approach is to expect you to provide an image that is tinted accordingly. So if you wanted to change that gray overlay to red you would need to call
setBackgroundImage:forState:and supply an appropriately tinted image that would be swapped in.Unfortunately there is no direct access in the SDK/API that will let you change the default highlight color – just the image.