Can we hide a UIView partially in iOS - ios

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.
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.

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.

Related

Desaturate colors in views below a UIView

Is it possible to set a backgrounds image such that the views drawn below it are desaturated, rather than just darkened or tinted via a normal alpha value.
I do not have the ability to alter the views below, so it must be contained to the UIView or layer.
Thanks!
Sure, just overlay the view with a screenshot (How Do I Take a Screen Shot of a UIView?) and desaturate (ios sdk desaturate image).
Then you can display other viewcontroller modally with transparent background to see-through your desaturated image (iOS: Modal ViewController with transparent background).

Hiding and showing UILabel with rounded corner and shadow in Swift 2

I am using this method Swift - Problems with corner radius and drop shadow to add rounded corners and shadow to a UILabel.
However, I need to hide and unhide the label depending on content. I am setting hidden true/false in my ViewController class. But the shadow layer still shows.
See example images below.
What is the best way to hide/unhide this shadow layer as well?
Set the alpha to 0:
myLabel.alpha = 0

mysterious white antialiasing behind UIImageView

I'm using a PageViewController to swipe through a series of daily ViewControllers for a week.
The UIViewController that contains the pageViewController contains a few navigation items that do not scroll with the pageViewController. These stay stationary as you swipe. One of these items is a UIImageView, more specifically a UIButton with an UIImageView image representation.
The trouble I'm having is that this stationary UIImageView has a thin white border to it when it should not. I'm giving it a rounded appearance by using rounded corners that are the size of the image. It is easiest seen in this photo. Note, the white "halo" is not part of the image, it appears for any image. The borderColor, imageBackground, view background, and parent view backgrounds are all clearColor. The red background below is part of the swipeable viewController. Interestingly, the white border only appears when it is stationary. If the image/button is placed in the swipeable View it looks great.
Any thoughts how I can get rid of this white antialiasing?
I changed the button's image from using the backgroundImage to just the image property and the white went away entirely. Glad for an easy fix, hope this helps someone else.

Subclassing UITableView to overlay a rectangle on the table frame

Aim: To draw a tableview with a rectangle at the bottom (frame bottom and not the scroll bottom). I plan to use some blend mode for the rectangle. The resultant effect would be of the last row sliding from under the rectangle.
What I Have Done: Tried subclassing UITableView and drawing a rectangle in its drawRect(). But this draws a rectangle either above or below the table and not over it.
Update: Tried subclassing a UIView and drawing the table and rectangle inside it. But the table hides the rectangle and I have to set the table background to clear for the rectangle to be visible.
Please help.

testing for taps on graphics drawn in a UIView

I have drawn a non-rectangular shape into a UIView subclass using core graphics. Now I want to make this shape "tappable", but not the areas of the UIView that is transparent. IE the UIView subclass background color is alpha 0. When the user taps off of the graphic itself, but still on the view, how do I test this so I can do an appropriate action, or not?

Resources