Slide in/out child view controller partially visible on parent view controller in Swift - ios

I have built two separate UIViewControllers: MainVC and 2ndVC. Now I am trying to connect them and achieve the effect presented on the image below:
When loaded, 2ndVC should be visible partially on top of MainVC (let's say 1/4 of the screen). On swipe up 2ndVC should cover whole screen and on swipe down it should go back to starting point. I have some buttons on MainVC which I would like to stay active when 2ndVC does not cover whole screen.
2ndVC's height will change dynamically dependently on data. It has scrollview inside which should be active only when it covers whole screen.
What is the best way to do that? Should 2ndVC be embedded in container view as a child view controller? Should I somehow animate constraints of 2ndVC programmatically on swipe?

Probably a Container View Controller is what you are looking for:
https://developer.apple.com/library/content/featuredarticles/ViewControllerPGforiPhoneOS/ImplementingaContainerViewController.html

Related

How to make a view controller adopt the same size as its distant ancestor's container view?

This will be easiest to explain with a diagram:
Here the initial view controller has a container view which contains the tab bar controller (note that the red bar at the top is a view, the initial view controller is NOT a navigation controller).
Any views displayed by the tab bar controller will occupy the same dimensions as the container view. Therefore when the blue VC is displayed the screen will continue to show the red view.
If when the button on the blue VC is clicked the green VC is presented modally and it occupies the full screen and thus covers the red view.
My question is, is there a simple way to make the green view controller occupy the same dimensions as its grand parent's container view so that the red view will be visible when the green VC is displayed.
(By simple, I don't want to do anything involving strong coupling such as the green vc obtaining the explicit dimensions of the container view and setting its dimensions to match. I'm hoping there's a setting in the storyboard or a different way of presenting the vc which will result in it automatically adopting the same size as its parent).
Yes I know the intitial view controller could be a navigation controller, we don't need to discuss why its not.

How to create a view above navigation bar or other screen content?

I would like to have a view above the navigation bar, or above any screen content if there isn't a navigation bar on that screen, so that it essentially reduces the height of everything else and doesn't cover any content. I also would like this view allow interaction (i.e. if its tapped, it would do something).
I have tried
UIApplication.sharedApplication().keyWindow?.addSubview(view) but that just overlays the view.
Here is a visualization:
Don't think of it in terms of above, think of it as beside - a sibling view.
So, create your own root view controller with that view and a container view below it, then add your 'normal' root navigation controller (or whatever) as a child view controller into the container view.

(Swift) Adding Pinned Navigation Bar to UICollectionView

I have a UICollectionView that scrolls with a bunch of images and I want to have a pinned Navigation Bar on the top that stays there even as you scroll. I moved the cell down in the UICollectionView in order to make room for a navigation bar and I dragged one into the View. I can see it in my story board however it is just a black view when I run the app. Can anyone please show me how to make this nav bar appear and how to make it stay pinned at the top even as you scroll. Thank you so so much. (I tried to attach photos of my problem but it says I do not have enough reputation to post images) I hope you guys are able to understand my problem and direct me in a way in which I could add a navigation bar that stays pinned on the top of a CollectionViewController
Drag a navigation controller into your storyboard. You probably want to position it just to the left of the view controller that has the collection view.
Delete the view controller that Xcode automatically attaches to the navigation controller.
Right click on the navigation controller and drag from root view controller over to your view controller where you have your collection view.
If necessary, move all segues that went to the collection view to the navigation controller instead.

iOS - pushViewController without sliding Background Image

Messing around with pushViewcontroller due to one of the awkward requirement :/
So there is a rootViewcontroller with 1 Background Image and UITableView with custom cells and there is a detailViewController with similar backgruound image with different views.
Requirement is:
On tap of UITableViewCell... the whole navigation animation should not affect the background image. Background Image should stay as it is and all other view should slide.
How I can slide only UITableView and display detail screen without changing background image ?
There is one possible solution is just add 2 child view controller and apply slide animation on both child. But in that case I have to keep on removing the child. I can't remove child because on tap of custom bottom back button I have to display the 1st screen instantly.
Any other possible solution or improvement ?
You can wrap your UINavigationController in a custom view controller that contains the background image. Then make sure your content view, as well as the pushed controller's views have a clear background.

Flipboard ipad app: right menu panel slide effect

how to implement right panel slide effect like following picture? when click left area, the right panel is hidden.
picture url http://cdn.thenextweb.com/wp-content/blogs.dir/1/files/2012/02/photo.png
I think
it is not popover controller.
is it a view added by using "addSubview"? I don't think so because it is a navigation controller,it seems that view in navigation controller can't be added by using addsubview
is it a modal view? if yes, how to implement semi transparent background? if use UIModalPresentationCurrentContext to present modal view, parent view can't rotate when ipad is rotated.
Any help is highly appreciated! Thanks.
These are all likely highly customized view controllers, and view controller containers.
You can fully control the presentation of your view controllers by adding them as children of another view controller, and adding their views to the view tree manually -- using any animation you choose.
The dimming effect you see can be achieved by overlaying a "dimming view", for example a black 50% opaque view.

Resources