Conditional overlapping view transparency? - ios

I have a few moving views which are semi-transparent, at some point they will be overlapping. Is it possible to make the overlapped part "invisible" through the top most view?
For example, 3 UIViews a background (which is stationary) and 2 subviews (the semi-transparent ones) and when they overlap the lower subview will be "invisible" under the top subview, all the while i can still see the background view and the part of the lower subview which isn't overlapping the other view.
Here's an image to help clarify the before and after they overlap.
Before Overlap:
After Overlap:
(the view on the far right looks a little strange because it blends with the white background)

Related

Partially show imageview

I am trying to create an animation where an image view is moving up and down vertically. I have a line that the imageview is passing through, and my intention is to have the imageview hide partially when passing through the line. For example, if the line is halfway between the imageview, then the bottom half of the imageview should be hidden. Therefore, it would be ideal if there was a library of function that could hide a fraction of the imageview based on a specified y position. Please find examples of what I mean in the attached screenshots.
In this screenshot, the part of the circle (imageview) underneath the line should be hidden, but the top half should be shown.
Also, keep in mind that the background is a changing gradient so I wouldn't be able to use a rectangular view with the same background color to hide the circle.

UITableView and UINavigationBar customization confusion. Any advice on how this was done?

Here is a part of the AirBnB app I would like built.
Here are the 3 questions that I'm in need of advice on.
How do i get a cell on a UITableView to act like the [ MORE FILTERS ] button? The button seems to act like a UITableView cell that always stay at the top. YET, it fades away just before going out of scope. Is this even a tableViewCell?
The view [ARRIVES | DEPARTS]. What view is this on a UITableView? When the tableView is scrolled all the way to the top it connects seamlessly with the [MORE FILTERS] button making it seem like its one view. But when the tableView starts scrolling, the [MORE FILTERS] button can be seen sliding over it as it fades away.
What is the [SHOW FILTERS] button? Is it a UINavigationItem titleView property or some separate view? As the table scrolls up it can be seen attaching itself to the UINavigationBar in a fade transition. At first i thought it was a just a UINavigationBarItem, but I do not know how to add items under the title of the bar. Any clarification on what this is or how can be accomplished?
I have already looked at Apple's Example on customized UINavigationBar, but it doesnt provide any clues to accomplish this. Any help appreciated
just like you did, when I came across an application like this one which has cool UI effects and animation, I would like to analyse and if possible try to do the same effect by myself, so that I could get innovations as well as knowledges.
Let's analyse it first, at the meantime you will probably find all the answers. I just drew a graph which shows the UI hierarchy of the screen, of course this hierarchy is based on my analysis, I cannot guarantee that the hierarchy is 100% correct.
I will do a bit of explanations here. From top to bottom:
1. The Navigation Bar(Red), just a opaque navigation bar, nothing special;
2. The Show Filters View(Purple) is a view which anchors to the bottom of the Navigation Bar(Red), and it is hided when the screen launches. Please note that this view is not a subview of Arrives & Departs View(Blue). It is added directly to the view controller's root view. Which means Purple and Blue are siblings;
3. The Arrives & Departs View(Blue), nothing special;
4. The More Filters View(Green), nothing special;
5. The Table View(Orange), nothing special;
So from my analysis, Purple, Blue, Green and Orange are all siblings.
Now let's move on to the fancy UI effects and animations. The trick here is you need to observe the change of the table view's contentOffset (I recommend to do it in the scroll view's delegate - scrollViewDidScroll), and move, hide or show the views accordingly. There are four stages:
1. The initial stage, like the graph above.
2. The Blue starts fading out, Green moves up as the finger moves, Orange increases its height. (Purple is still at the same position and hided, I just removed it from the graph in order to make it clearer);
Blue totally faded out, Green starts fading out and Purple starts fading in. Orange is still doing the same - increasing its height;
Green totally faded out, Purple totally faded in and Orange increases its height to fill the screen and then anchors to the bottom of Purple.
The [MORE FILTERS] button does appear to be a cell of the UITableView. Since it is a different type of cell than the other cells containing the UIImageView and the UILabels using a different identifier you can tell the cell to fade away with an animation. Try this link for more information.
The [ARRIVES | DEPARTS] seems to be its own view. I believe that this and the tableview are both part of a UIScrollView. This is the reason that it seamlessly disappears when the [MORE FILTERS] cell scrolls up towards it.
The [SHOW FILTERS] button could just be a part of the navigation bar. When the scrollView finishes scrolling the navigation bar can be extended. However, it is also possible that the button is in a view of its own and is hidden until the scrollview finishes scrolling. Either way should be possible but I would recommend putting it in its own view rather than attaching it to the navigation bar.

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.

Autolayout whem view are hidden

I know that there is 2 approaches when dealing with autolayout and hidden views:
Remove hidden view from hierarchy and add it back when needed
Change UIViews constraints to ignore hidden view
I have some complex case (imo). Here is my layout
Gray view is container view in my hierarchy on the left.
I have 3 blocks: green, yellow and red. Red and yellow also have titles (see small rects of the same color).
So the problem is that yellow and red could be empty. Adding view back would have rather difficult code (for example adding red):
I have to check if yellow block is here
I have to set lots of constraints in code. I could easily break my UI by changing constraints on Storyboard and not change it in code.
I need to hide red/yellow views when there is no info and show them again when there is some info (without reloading whole controller)
Are there any solutions without that problems?

Objective C - drawing on top of existing subviews [duplicate]

This question already has answers here:
drawRect over subviews?
(3 answers)
Closed 8 years ago.
I have a UIView that I've designed in xib:
You can see that it consists of three things: Two large views on either side which are just empty for now, and then a gray bar in the middle (which is itself a UIView).
In some conditions, I want to draw horizontal blue lines on top of the entire page. But what's happening is that because of the views on the left and right, the horizontal blue lines are only showing in the middle. How can I draw ON TOP of the views that exist within my view? In other words, how do I get those blue lines to show up on the whole screen (the drawing commands have them being drawn much longer than they show up as). Stated another way, I need to set the Z dimension of my blue lines to be on top of everything else.
I would have this sort of view hierarchy:
Main view has 3 subviews: left, right, center. Center is in front of left and right, and is sized so that it fits the width of the blue bars.
Center has a subview that is the vertical line, and a subview that contains the blue lines, and is made to have a transparent background. The vertical line view should have Z dimension higher than the one containing the blue lines.
When you draw the center, you can set the blue lines subview to be visible/invisible as needed.

Resources