-1

I have a cell, which is a view,that contains other views, which formed a one of cell from Expectations image

I need to show it with different transparency, and the case to set background color alpha value is not suitable, remain only set alpha to whole view, in test ground it setted three views with alpha that i need, but faced the next trouble

Reality

blue view alpha = 1.f 
red view alpha = 0.5f
green view alpha = 0.75f

That transparent views is overlapping each other, on screenshot you can see that transparent red view is "seen" under transparent green view. So i need to exclude somehow red view underneath, with mask of green view on top.

Any suggestion how i can achieve that? Any methods that return UIBezierPath with excluded figure or path ?


UPDATE 1

A views is need to be transparent, because behind them will be an image, and purpose of the views is "comment cells". So the users must leave comments and the the image on background thorough comments

Mr.Fingers
  • 1,105
  • 1
  • 11
  • 15
  • If you do not want to see the content below, why do you want *transparent* views? You can just adjust the color value as per you expectation. – Swapnil Luktuke Apr 24 '17 at 09:18
  • Underneath the "expectations" image will be image, and those cells its a comments on photo. And it needed to be transparent with different values. – Mr.Fingers Apr 24 '17 at 09:20
  • Directly setting the alpha values of the views will definitely not work if the views have to overlap. You need to override the view drawing code and fill the color in graphics context. You need to have very robust code to calculate the area which should be 'filled' with the color. – Swapnil Luktuke Apr 24 '17 at 09:25
  • I know that i need to draw all by myself, but i hope it will be last instance of my trouble, I'm looking for some more elegant method, where i take a forms of "green view", and exclude the intersected area of "red view" with mask, or something like that – Mr.Fingers Apr 24 '17 at 09:29
  • You are thinking in the right direction... you can find many examples for using one path to clip another path etc. Some examples: 1. http://stackoverflow.com/questions/1021801/cgpathref-intersection 2. http://stackoverflow.com/questions/14411765/ios-invert-mask-in-drawrect 3. http://stackoverflow.com/questions/8721019/drawrect-drawing-transparent-text . The most complicated part then, is finding the 'relative' positions of these paths for masking / intersecting /clipping. – Swapnil Luktuke Apr 24 '17 at 09:37

1 Answers1

0

Just add a white colored view behind your transparent views.

Also give alpha to color and not to view. enter image description here