View Controller Transparent Background - ios

How can I create a view controller with a transparent background that overlays another view controller where the bottom view controller is still visible in iOS 9? The way that works in iOS 8 no longer works.

First you can set overlaid view controller's background colour as clear colour.
You can use presentViewController method to overlay new view controller.
This from apple docs
When presenting a view controller using the UIModalPresentationFullScreen style, UIKit normally removes the views of the underlying view controller after the transition animations finish. You can prevent the removal of those views by specifying the UIModalPresentationOverFullScreen style instead.
So you can set overlaid view controller's modalPresentationStyle to UIModalPresentationOverFullScreen
I also hope this may be help
When using one of the full-screen presentation styles, the view controller that initiates the presentation must itself cover the entire screen. If the presenting view controller does not cover the screen, UIKit walks up the view controller hierarchy until it finds one that does. If it can’t find an intermediate view controller that fills the screen, UIKit uses the root view controller of the window.

To solve this problem you just have to change the Alpha information of your View. To get this view on top of others, change the Transition Style of the ViewController.

FYI: The syntax is now:
childVC.modalPresentationStyle = UIModalPresentationStyle.OverFullScreen

Related

What is the difference between the modal presentation style "over current context" and "over fullscreen"?

I wonder what the difference between current context and over fullscreen is?
When I switch between them I don't see any changes in my app. All the animations look the same etc.
There aren't any visual differences if you are presenting a view controller from a view controller that is already in full screen mode. However, if the presenting view controller isn't in full screen mode, the current context will make a different. For example:
Left: before present, the current view controller is not in full screen mode
Middle: presenting a new view controller with full screen
Right: presenting a new view controller with current context
A full list of comparison of different presentation mode available here on Github.
fullScreen:
The presented view covers the screen (fullscreen).
currentContext:
The UIModalPresentationCurrentContext style covers a specific view controller in your interface. When using the contextual style, you designate which view controller you want to cover by setting its definesPresentationContext property to true.
When presenting a view controller using the
UIModalPresentationFullScreen style, UIKit normally removes the views
of the underlying view controller after the transition animations
finish. You can prevent the removal of those views by specifying the
UIModalPresentationOverCurrentContext style instead. You might use
that style when the presented view controller has transparent areas
that let underlying content show through.
Read more about presenting viewControllers here.

Unable to set a dim background to a modal view

I'm developing an app targeting iOS 7 and above. I'd like to present modally a view with a dim background that partially shows the previous view below. I've read several posts dealing with this scenario, and I did:
Created a view controller scene in storyboard and set a modal segue to navigate to it.
Set the Presentation value of that modal segue to Current Context.
Set the view controller's view background color to clear color.
Added a full-screen view above the parent view, with black color background and 50% opacity.
Transition to the modal view is default and animated. While the animation, I see the view being presented as semi-transparent, but once the transition animation ends and view finally occupies the full screen, the view becomes opaque black.
What I'm doing wrong? How could I solve this?
As #luk2302 said, when you present a view controller modally, iOS removes the view controllers underneath it from the view hierarchy so is nothing underneath it except the app window, which is black. Anyway, iOS 7 has a new modal presentation style, UIModalPresentationCustom, that forces iOS not to remove the views underneath the presented view controller. But you must provide your own transition delegate to handle the presentation and dismiss animations
Check this link how to implement custom transition delegate.

How to change color what is under self.view

I want to change color what is unde self.view. For example in navigation controller I just can change background of navigation controller, but how to change it on simple view controller ?
That is the window that the app runs in.
You shouldn't really be messing with it. Your UIViewController's views should be covering it completely.
Beginning in iOS7, you can make container view controllers to present other view controllers. Changing the background color of the container view would effectively provide the functionality you're looking for

How to fade whole screen

I am presenting a temporary view on top of my view controller when a user does some action.
I want it to fade the screen - including the navigation bar, like UIActionSheet does.
I am presenting the view via the root view controller of the navigation controller, so my only problem is to fade also the navigation bar and not allow touches on it.
How can I do that?
You can add a semi-transparent view on the whole UIWindow and it'll look just as you described it. You'd probably want to add your temporary view there, too, because all actions will be blocked by the semi-transparent view.

Using iOS 6 autolayout, what would be the proper way to display somthing above an UINavigationController?

In my app, i have a main view controller which sometimes brings a modal view on top of it. This modal view is a UINavigationController with a navigation bar. I want to display an image above the navigation bar, and have the navigation bar appear below the image.
I do not want to subclass anything and the app uses autolayout, i do not want a bunch of delegate callbacks and frame calculations. The view inside the navigation controller (the actual modal content) must still respond to different screen sizes correctly, such as rotation, call status bar etc. Also, no IB solutions please, these views are all managed in code.
How do i accomplish this?
I would turn off AutoLayout and place the image at the top
I don't think you can do it with your modal view being a navigation controller. I would do it by making that modal controller a UIViewController that you set up as a custom container controller. You can add an image view to the top of this controller's view and add the view of a child view controller (which would be a navigation controller) to the bottom. This would be a lot easier to do in a storyboard using container views, but it certainly can be done in code.

Resources