0

what I was trying to do was to make a UIImageView darker so that the buttons and views on top of the image result. I wanted to give it the effect that is given when in ios6 a user shares using Facebook. All the content behind it becomes darker but it is visible. I tried using the:

[myImageView setOpaque:YES];

but it doesn't do anything. Any ideas?

Alessandro
  • 4,000
  • 12
  • 63
  • 131

1 Answers1

2

I believe if i understand you well is to darken an uiimageview after a button was clicked and the imageview is not the button image right?

If so what you can do is when the button is clicked, you add a mask to the uimageview layer. you create a masking layer like this

CALayer * layer = [CALayer layer];
layer.frame = yourImageView.bounds;
layer.backgroundColor = [UIcolor colorWithWhite:0.f alpha:.5f].CGColor;
[yourImageView.layer setMask:layer];

you can change of course the alpha value 1 make it totaly dark 0 makes it totally transparent. Okay maybe this code doesn't work with uiimageview I'm sorry. It works with UIView and UIscrollViews. I don't know how to do it then... Sorry

Nicolas Manzini
  • 8,379
  • 6
  • 63
  • 81
  • I used your coad exacly as it is and my image view is just invisible, as if it was hidden. am I doing something wrong? – Alessandro Jan 20 '13 at 19:46
  • http://stackoverflow.com/questions/5757386/how-to-mask-an-uiimageview actually the code i showed you should work look at the answer with 26 likes – Nicolas Manzini Jan 20 '13 at 19:58
  • but the answer and question are different. it is asking how to mask an image with another image – Alessandro Jan 20 '13 at 20:14