iOS - Semi-transparent modal view controller

present view controller with transparent background objective-c
present view controller with transparent background swift 4
present modal view controller in half size parent controller swift
modal view ios
ios swipe up view controller
swift modal popup
swift popup view programmatically
ios slide view up from bottom

I want to present a view controller with a slightly transparent background modally over the current view, such that the first view is slightly visible under the modal view.

I set the alpha value of the modal view controller and set the modalPresentationStyle to UIModalPresentationCurrentContext, as suggested in another post.

The result is that the view background is transparent when animating up, but when view controller is in place it changes to opaque black. It goes back to being transparent while animating the dismissal.

How can I get it to be transparent when active ?

I have tested in iOS 6 and 7. The code I am using follows:

MyModalViewController *viewController = [[MyModalViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
[navController setNavigationBarHidden:YES];
self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;
[self.navigationController presentViewController:navController animated:YES completion:NULL];

iOS 8 added a new modal presentation style specifically for this purpose:

presentedViewController.modalPresentationStyle = UIModalPresentationOverFullScreen

From the spec:

UIModalPresentationOverFullScreen

A view presentation style in which the presented view covers the screen. The views beneath the presented content are not removed from the view hierarchy when the presentation finishes. So if the presented view controller does not fill the screen with opaque content, the underlying content shows through.

iOS Semi-Transparent Modal Views, Showing the Modal. Open the Main. Drag a button onto the view and name it “Show Modal” or something similar. Drag a ViewController into the storyboard. Control-drag from the button to the new ViewController and create a modal segue. Change the background color of the new ViewController's view to be clearColor. For those trying to get this to work in iOS 8, the “Apple-approved” way to display a transparent modal view controller is by setting modalPresentationStyle on the present ed controller to UIModalPresentationOverCurrentContext. This can be done in code, or by setting the properties of the segue in the storyboard.


If you are targeting ios 8 and above you can set the modal presentation style to "over current context" and you are done. If ios 7 and below, you would have to create a custom transition style so that the presenting screen doesn't go blank after transition. That is rather complicated.

The solution I present offers a lot of flexibility: make a screenshot before showing the modal dialog and set that as the background image for the application window. By default, that background is black (that is what you see when the back view controller dissapears). Change the background to the screenshot of the app. Make the screenshot in the viewWillAppear or viewDidLoad method of your transparent view. This works even with push segues, not only modal dialogs, but you should avoid animations. In general, avoid animations which affect the position of the background view because those will make it seem like it snaps back into place when transition finishes. It is a good idea to reset the background to its previous black image on viewDidDissapear to avoid unwanted effects.

You can maintain a stack of such background images and you can do multiple "transparent" push seques. Or have some complex/deep menu which appears on top of some main screen. For these many reasons I think this solution is better than rolling your own transitioning code. It is more flexible and easier to implement, and you don't have to deal with the animations yourself.

iOS Blurred Background Modal View (Swift 3 + XCode Tutorial), in iOS applications is the implementation of semi-transparent modal Delete 2 of the files created by default, namely, ViewController.swift  Sets the modal View Controller property to the specified view controller. Resizes its view and attaches it to the view hierarchy. Resizes its view and attaches it to the view hierarchy. The view is animated according to the transition style specified in the modal Transition Style property of the controller in the modal View Controller parameter.


The reason that the BG view controllers disappear after a modal is shown is that the default transition in iOS 7 removes the BG view after animation completed. If you define your own transition and you set your BG view not to be removed (just changing its alpha) then you will have the transparent modal view.

Presenting a UIViewController modally, with custom animations, modalPresentationStyle = UIModalPresentationCustom; viewController. always remain in the back and if your presented view controller sets a semi transparent background you will get a very stylish effect. This solution works for iOS 7+  Animate transition for presenting your modal view controller. See SimpleTransitionViewController example in the Example project. mySimpleTransitioningDelegate. transitionPresent = {[weak self] (fromViewController: UIViewController, toViewController: UIViewController, containerView: UIView, transitionType: TransitionType, completion: @escaping


Same problem occured to me. I have solved it by looking at the following url about a custom alert controller. I managed to get it working even with a UINavigationController.

Swift
let viewController = UIViewController()
viewController.providesPresentationContextTransitionStyle = true
viewController.definesPresentationContext = true
viewController.modalPresentationStyle = .overCurrentContext
viewController.modalTransitionStyle = .crossDissolve
DispatchQueue.main.async {
    self.navigationController?.present(viewController, animated: true, completion: nil)
}
Objective C
UIViewController *viewController = [UIViewController new];
viewController.providesPresentationContextTransitionStyle = true;
viewController.definesPresentationContext = true;
viewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
viewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

dispatch_async(dispatch_get_main_queue(), ^{
    [self.navigationController presentViewController:viewController animated:true completion:nil];
});

How to implement transparent modal view on iPhone?, You can easily make a transparent modal view using custom segue. This is [​sourceViewController presentViewController:modalViewController animated:NO​  Coordinate the modal view appearance with your app. For example, when a modal view includes a navigation bar, it should use the same appearance as the navigation bar in your app. Choose a modal transition style that makes sense in your app. Use a transition style that coordinates with your app and enhances the awareness of the temporary context shift.


Here is a solution.

Create your presenting view controller. Add a backView to this view controller's main view. Name this as backView.

In SecondViewController.m

-(void)viewDidLoad
{
    // Make the main view's background clear, the second view's background transparent.
    self.view.backgroundColor = [UIColor clearColor];
    UIView* backView = [[UIView alloc] initWithFrame:self.view.frame];
    backView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
    [self.view addSubview:backView];
}

Now you have a view controller with half transparent background. You can add anything you want to the self.view , the rest will be half transparent.

After that, in FirstViewController.m

self.modalPresentationStyle = UIModalPresentationCurrentContext;

[self presentViewController:secondViewController animated:YES completion:nil];

Presenting a modal ViewController which has semi transparent , After iOS 3.2 there is a method to do this without any “tricks” – see the documentation for the modalPresentationStyle property. You have a rootViewController  Pass property from Modal View Controller to Parent Tag: ios , objective-c , cocoa-touch , uiviewcontroller , modalviewcontroller I have a tableview as a parent view controller with a child modal view controller.


Transparent Background on a modal View controller, In the presenting View Controller add the following code if you want to support iOS7. // For iOS modal presentation style must be set on presenting  The top-most view is dismissed using its modal transition style, which may differ from the styles used by other view controllers lower in the stack. If you want to retain a reference to the receiver' s presented view controller, get the value in the modal View Controller property before calling this method.


Swift Modal View Controller with transparent background · GitHub, You can do it like this: In your main view controller: func showModal() { let modalViewController = ModalViewController() modalViewController. As of iOS 13, dismissing my modally presented view controller does not trigger 'viewWillAppear' on the previous view controller.


Show popover with a clear background - Fresh Beginning, The viewController might have one or more subviews as its children. To give you an idea, this modal should look something like this, (Note: I have changed background from clearColor to transparent black color to give an idea on which part of After years of iOS development, I finally caved & made. Custom UIViewController. When it comes to implementing modals in iOS, there are several approaches that will give you similar results. The first approach is the most flexible and involves making a custom view to contain the entire contents of the modal. This custom view is very similar every other view that you make,