0

I have to partially hide a UIView when user scrolls over it. There is a UIScrollView above UIView. For example in the given image below i want to hide the area covered under the scrollable area which is in blue color. All my views background colors are clear color.

enter image description here

I want to hide the part as given in the below image, the marked rectangle which is in red color. So that part of text (One, Two, Three) is only visible. enter image description here

UditS
  • 1,936
  • 17
  • 37
vishy
  • 3,241
  • 1
  • 20
  • 25
  • 1
    You can add another `UIView` above it to hide scrollable area. – iAnurag Jan 27 '16 at 10:50
  • And what do you want to hide it with? Is there some other view added in scroll view that you want to make visible when user scrolls ? – UditS Jan 27 '16 at 10:50
  • 1
    What do you mean by hiding it partially? do you mean hide it while scrolling and showing it back when scrolling stops? – Ismail Jan 27 '16 at 10:52
  • There is a content in the blue area, on scroll the side content (one, two, three) should fade out. The full screen is scrollable (in width) – vishy Jan 27 '16 at 10:56
  • 1
    Are you looking for a Slide-out menu effect ? A view to be added on partial width of the screen on scroll? – UditS Jan 27 '16 at 11:03
  • something similar but using scrollview, i give a solid background color instead of reduced opacity it works fine. Is there a way to have an hidden mask layer at the corner of scrollview. – vishy Jan 27 '16 at 11:07

1 Answers1

1

Each UIView, including UIScrollView, has a Core Animation Layer (a CALayer).

You access the CALayer with

view.layer

In turn, a CALayer has a mask, which you access with

layer.mask

Using the mask is the most comprehensive method of controlling visibility and opacity at runtime.

SwiftArchitect
  • 47,376
  • 28
  • 140
  • 179
  • Using mask layer i don't think we could hide partially, as soon as we add mask layer to view it will be hidden. I managed by adding a UIView and updating the right zPosition. – vishy Feb 01 '16 at 06:09