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.
Related
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.
As seen in screenshot, I have two stationary green and red views side by side.
Blue view is dragable.
What I want is, when the blue view is dragged between green and red view, to move red and green views and make space for the blue view to be dropped. If blue view is dropped elsewhere, it is to return to its original position.
I am able to drag the blue view, but not sure how to "Detect when the blue view is in between green and red and then drop it in place". Help in swift will be highly appreciated.
I was able to solve this (thanks to #rdelmar pointer).
1) Use 'CGRectIntersectsRec' to test when blue view is intersecting with both red and green.
2) Move red to right and green to left by half their width.
3) Copy blue view's size to create an invisible new view and place it between red and green.
4) test for when blue view is NOT intersecting with new invisible view, then remove the invisible view and move back red and green.
I have a View and i have a an image view inside it and a another UiView and one or two more view in side the top level view. The problem is when i run my app in different screens iphone the image view resizes and i want the other view to change the their position to a little bit down. But only image view gets more space, but i don't want the other view to get more space but i want them to change their position.
Here i want the white view the Placeholder text and the the small picture view to change their position and go a bit down when the app runs on big screen iphone. Th rounded image view above the Mybutton gets more space when the screen resizes which is okay but the white view and other view remain at their same place. Just to add more information all these view are siblings of each other and i have fixed the the width and height of the white view, picture view and the placeholder text label
Any guidance please?
I think you have to start with the "movable" element and then add every "fixed" element.
I think you have to work with Center Y Alignment Contraint even if you have to create new view for it. The beginning could be :
I'm using UICollectionView with different sections, the problem is within a section if there are not enough item, the only items are centred, is there a way to make it layout cells to be from left to right and top to bottom? Without adding transparent placeholder cells?
Thanks
edit:
Screen shot added, so section 1 has the big orange bar and two small green bars, the one on the right of big orange bar should be in section 1, so I want it to be below the big orange bar, next to another green bar which is already there.
Also, say if section 1 has only 1 big orange bar, I want it to be top aligned, but it is centered.
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)