-3

I'm trining to change view's background color to opacity 10% from the storyboard, but when I run it on a device the color looks like the opacity is at 100%.

Also, I would prefer to not do this from code.

So here is how I set it. And I want to get the gray color, but instead I get the black one. What am I doing wrong?

enter image description here

razvan
  • 355
  • 4
  • 19
  • 1
    Possible duplicate of [Setting alpha on UIView sets the alpha on its subviews which should not happen](https://stackoverflow.com/questions/18681901/setting-alpha-on-uiview-sets-the-alpha-on-its-subviews-which-should-not-happen) – MRizwan33 Apr 30 '18 at 12:45
  • Please see this. https://stackoverflow.com/questions/18681901/setting-alpha-on-uiview-sets-the-alpha-on-its-subviews-which-should-not-happen/48014487#48014487 – MRizwan33 Apr 30 '18 at 12:45
  • You can apply alpha to color and view itself. So check which one should have alpha and change value for that property. – Sharad Chauhan Apr 30 '18 at 12:51
  • Are you trying to set the *view* to 10% (light) gray? Or are you trying to set the view to ***add 10% gray*** to whatever is behind it? – DonMag Apr 30 '18 at 12:53
  • @DonMag The first one. I'm trying to set the view to 10% (light) gray – razvan Apr 30 '18 at 12:57
  • @razvan - OK, that's not what Opacity does. Just set each of the R/G/B values to `25`, and leave Opacity at `100`... actually, that will be **dark gray**. If you want **light gray**, set the values to `225` and Opacity `100` (adjust the `225` value till you find your happy gray color). – DonMag Apr 30 '18 at 12:58
  • @DonMag as Emre Önder pointed out and I just realized that I actually get the color that I want, it's just that I have a black view under it. Thanks a lot all of you – razvan Apr 30 '18 at 13:08

1 Answers1

1

Please check If you have any View below that view. Also check If you are selecting right view. When I set RGB to 0 and make opacity to %10. I'm getting a light gray as you want.

Screenshot

Emre Önder
  • 2,408
  • 2
  • 23
  • 73