iOS: Modal ViewController con fondo transparente


Estoy tratando de presentar un controlador de vista modalmente, con un fondo transparente. Mi objetivo es permitir que tanto la vista presenting como la vista presented view controllers se muestren al mismo tiempo. El problema es que, cuando termina la animación de presentación, la vista del controlador de vista de presentación desaparece.

- (IBAction)pushModalViewControllerButtonPressed:(id)sender
{
    ModalViewController *modalVC = [[ModalViewController alloc] init];
    [self presentViewController:modalVC animated:YES completion:nil];
}

Sé que podría simplemente agregar la vista como una subview, pero me gustaría evitar esta solución por alguna razón. ¿Cómo podría arreglarlo?

Author: Ajumal, 2012-10-05

22 answers

Este siguiente código solo funciona en el iPad.

self.view.backgroundColor = [UIColor clearColor];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentModalViewController:modalVC animated:YES];

Yo iría con la adición de una vista secundaria.

Aquí hay una muy buena discusión. Mira los comentarios específicamente. No solo la respuesta.

Vista modal

Si yo fuera tú no lo haría. Agregaría una vista secundaria y lo haría. Parece que me da un mejor control sobre las cosas.

EDITAR:

Como lo mencionó Paul Linsay, ya que iOS 8 todo lo que se necesita es UIModalPresentationOverFullScreen para el modalPresentationStyle del ViewController que se está presentando. Esto también cubriría los botones NavigationBar y TabBar.

 80
Author: S.P.,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-10-12 20:21:04

Para aquellos que intentan que esto funcione en iOS 8, la forma" aprobada por Apple " de mostrar un controlador de vista modal transparente es configurando modalPresentationStyle en el presente ed controlador a UIModalPresentationOverCurrentContext.

Esto se puede hacer en código, o estableciendo las propiedades del segue en el guion gráfico.

De la documentación de UIViewController:

UIModalPresentationOverCurrentContext

Un estilo de presentación donde se muestra el contenido sólo el contenido del controlador de vista principal. Las vistas debajo de lo presentado el contenido no se elimina de la jerarquía de vistas cuando la presentación terminar. Así que si el controlador de vista presentado no llena la pantalla con contenido opaco, el contenido subyacente se muestra a través.

Al presentar un controlador de vista en una ventana emergente, esta presentación el estilo solo se admite si el estilo de transición es UIModalTransitionStyleCoverVertical. Intentar usar un método diferente transición el estilo activa una excepción. Sin embargo, puede utilizar otros estilos de transición (excepto la transición de curl parcial) si el padre view controller no está en una ventana emergente.

Disponible en iOS 8.0 y versiones posteriores.

Https://developer.apple.com/documentation/uikit/uiviewcontroller

El video 'View Controller Advancements in iOS 8' de WWDC 2014 entra en esto con cierto detalle.

Nota:

  • Asegúrese de dar su controlador de vista presentado un color de fondo claro, para que no sea realmente transparente!
  • Tiene que establecer esto antes de presentar ie establecer este parámetro en el viewDidLoad del presentedViewController no tendrá ningún efecto
 175
Author: Jeff C.,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-10-12 19:34:37

En iOS 8.0 y superior se puede hacer estableciendo la propiedad modalPresentationStyle a UIModalPresentationOverCurrentContext

//Set property **definesPresentationContext** YES to avoid presenting over presenting-viewController's navigation bar

self.definesPresentationContext = YES; //self is presenting view controller
presentedController.view.backgroundColor = [YOUR_COLOR with alpha OR clearColor]
presentedController.modalPresentationStyle = UIModalPresentationOverCurrentContext;

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

Ver Imagen Adjunta

 88
Author: sat20786,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-06-08 08:59:34

Este código funciona bien en iPhone bajo iOS6 e iOS7:

presentedVC.view.backgroundColor = YOUR_COLOR; // can be with 'alpha'
presentingVC.modalPresentationStyle = UIModalPresentationCurrentContext;
[presentingVC presentViewController:presentedVC animated:YES completion:NULL];

En este caso se pierde la animación de diapositivas. Para conservar la animación todavía se puede utilizar la siguiente extensión "no elegante":

[presentingVC presentViewController:presentedVC animated:YES completion:^{
    [presentedVC dismissViewControllerAnimated:NO completion:^{
        presentingVC.modalPresentationStyle = UIModalPresentationCurrentContext;
        [presentingVC presentViewController:presentedVC animated:NO completion:NULL];
    }];
}];

Si nuestro presentingV se encuentra dentro de UINavigationController o UITabBarController, necesita operar con esos controladores como presentingVC.

Además, en iOS7 puede implementar animación de transición personalizada aplicando el protocolo UIViewControllerTransitioningDelegate. Por supuesto, en este caso usted puede conseguir fondo transparente

@interface ModalViewController : UIViewController <UIViewControllerTransitioningDelegate>

Primero, antes de presentar hay que establecer modalPresentationStyle

modalViewController.modalPresentationStyle = UIModalPresentationCustom;

Entonces tienes que implementar dos métodos de protocolo

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source
{
    CustomAnimatedTransitioning *transitioning = [CustomAnimatedTransitioning new];
    transitioning.presenting = YES;
    return transitioning;
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
{
    CustomAnimatedTransitioning * transitioning = [CustomAnimatedTransitioning new];
    transitioning.presenting = NO;
    return transitioning;
}

Lo último es definir tu transición personalizada en CustomAnimatedTransitioning class

@interface CustomAnimatedTransitioning : NSObject <UIViewControllerAnimatedTransitioning>
@property (nonatomic) BOOL presenting;
@end

@implementation CurrentContextTransitionAnimator

- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext 
{
    return 0.25;
}

- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext 
{
    UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
    UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];

    if (self.presenting) {
        // custom presenting animation
    }
    else {
        // custom dismissing animation
    }
}
 42
Author: malex,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-08-19 22:06:30

Crear un segue para presentar modalmente y establecer la propiedad de presentación de ese segue en el contexto actual funcionará al 100%

introduzca la descripción de la imagen aquí

 15
Author: Venu Gopal Tewari,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-01-21 18:38:32

Tuve problemas con el Creador de interfaces de XCode 7 para establecer el Estilo de Presentación como sugirió @VenuGopalTewari. En esta versión, no parece haber un modo de presentación Over Current Context o Over Full Screen para el segue. Por lo tanto, para que funcione, establezco el modo en Default:

introduzca la descripción de la imagen aquí con introduzca la descripción de la imagen aquí

Además, establezco el modo de presentación del controlador de vista presentado modalmente en Over Full Screen:

introduzca la descripción de la imagen aquí

 14
Author: Bastian,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-10-14 10:26:24

PresentViewController con fondo transparente-en iOS 8 y iOS 9

MYViewController *myVC = [self.storyboard   instantiateViewControllerWithIdentifier:@"MYViewController"];
    myVC.providesPresentationContextTransitionStyle = YES;
    myVC.definesPresentationContext = YES;
    [myVC setModalPresentationStyle:UIModalPresentationOverCurrentContext];
    [self.navigationController presentViewController:myVC animated:YES completion:nil];

Y en MyViewController establecer el color de fondo negro y reducir la opacidad

 14
Author: Ashwini Chougale,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-06-23 09:21:00

Es un poco de hacky way, pero para mí este código funciona (iOS 6):

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

[self presentViewController:self.signInViewController animated:YES completion:^{
    [self.signInViewController dismissViewControllerAnimated:NO completion:^{
        appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
        [self presentViewController:self.signInViewController animated:NO completion:nil];
        appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;

    }];
}];

Este código funciona también en iPhone

 12
Author: Mak,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-09-24 11:29:40

Esta categoría funcionó para mí (ios 7, 8 y 9)

Archivo H

@interface UIViewController (navigation)
- (void) presentTransparentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion;
@end

M file

@implementation UIViewController (navigation)
- (void)presentTransparentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion
{
    if(SYSTEM_VERSION_LESS_THAN(@"8.0")) {
        [self presentIOS7TransparentController:viewControllerToPresent withCompletion:completion];

    }else{
        viewControllerToPresent.modalPresentationStyle = UIModalPresentationOverCurrentContext;
         [self presentViewController:viewControllerToPresent animated:YES completion:completion];
    }
}
-(void)presentIOS7TransparentController:(UIViewController *)viewControllerToPresent withCompletion:(void(^)(void))completion
{
    UIViewController *presentingVC = self;
    UIViewController *root = self;
    while (root.parentViewController) {
        root = root.parentViewController;
    }
    UIModalPresentationStyle orginalStyle = root.modalPresentationStyle;
    root.modalPresentationStyle = UIModalPresentationCurrentContext;
    [presentingVC presentViewController:viewControllerToPresent animated:YES completion:^{
        root.modalPresentationStyle = orginalStyle;
    }];
}
@end
 11
Author: Ted,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-10-14 06:36:39

He añadido estas tres líneas en el método init en el controlador de vista presentado, y funciona como un encanto:

self.providesPresentationContextTransitionStyle = YES;
self.definesPresentationContext = YES;
[self setModalPresentationStyle:UIModalPresentationOverCurrentContext];

EDITAR (trabajando en iOS 9.3):

self.modalPresentationStyle = UIModalPresentationOverFullScreen;

Según la documentación:

UIModalPresentationOverFullScreen Un estilo de presentación de vista en el que la vista presentada cubre la pantalla. Las vistas debajo del contenido presentado no se eliminan de la jerarquía de vistas cuando finaliza la presentación. Así que si el controlador de vista presentado no llena la pantalla con contenido opaco, el contenido subyacente se muestra a través.

Disponible en iOS 8.0 y versiones posteriores.

 6
Author: inigo333,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-04-15 17:33:54

La forma alternativa es usar una "vista de contenedor". Simplemente haga alfa por debajo de 1 e incruste con seque. XCode 5, objetivo iOS7. Probado en iPhone.

introduzca la descripción de la imagen aquí

Vista de contenedor disponible desde iOS6. Enlace a la publicación del blog sobre eso.

 4
Author: Mike Glukhov,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-03-25 07:28:50

Si estás usando Storyboard, puedes seguir este paso:

  1. Agregue un controlador de vista (V2), configure la interfaz de usuario de la manera que desee
  • añadir un UIView-establecer el fondo en negro y la opacidad a 0.5
  • agregue otro UIView(2) - que servirá como su ventana emergente (Por favor tome nota de que el UIView y el UIView(2) no deben tener el mismo nivel/jerarquía. No hacer la imageview el hijo de la vista de lo contrario la opacidad de la uiview afectará a la UIView (2))
  1. Presente V2 Modalmente

  2. Haga clic en el segue. En el inspector de atributos, Establezca La Presentación como En Pantalla completa. Eliminar animación si te gusta

Storyboard

  1. Seleccione V2. En el inspector de atributos, Establezca La Presentación como En Pantalla completa. Check Define el Contexto y Proporciona el Contexto

Storyboard

  1. Seleccione la vista principal de su V2 (Pls. Compruebe la imagen). Set backgroundColor to Clear Color

Storyboard

 4
Author: dhin,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-09-20 03:24:06

He creado un objeto para manejar la presentación de lo que llamo un "modal superpuesto", lo que significa que conserva la vista del fondo y le permite tener un modal con un fondo transparente.

Tiene un método único y simple que hace esto:

- (void)presentViewController:(UIViewController *)presentedViewController
       fromViewController:(UIViewController *)presentingViewController
{
    presentedViewController.modalPresentationStyle = UIModalPresentationCustom;
    presentedViewController.transitioningDelegate = self;
    presentedViewController.modalPresentationCapturesStatusBarAppearance = YES;

    [presentedViewController setNeedsStatusBarAppearanceUpdate];

    [presentingViewController presentViewController:presentedViewController
                                       animated:YES
                                     completion:nil];
}

Es importante establecer la propiedad modalPresentationCapturesStatusBarAppearance en YES y forzar que se actualice la apariencia de la barra de estado, si su controlador de vista presentado tiene un preferredStatusBarStyle diferente.

Este objeto debe tener un @property (assign, nonatommic) isPresenting

Quieres este objetivo es cumplir con los protocolos UIViewControllerAnimatedTransitioning y UIViewControllerTransitioningDelegate e implementar los siguientes métodos:

- (id)animationControllerForPresentedController:(UIViewController *)presented
                           presentingController:(UIViewController *)presenting
                               sourceController:(UIViewController *)source
{
    self.isPresenting = YES;

    return self;
}

- (id)animationControllerForDismissedController:(UIViewController *)dismissed
{
    self.isPresenting = NO;

    return self;
}

Y:

- (NSTimeInterval)transitionDuration:(id)transitionContext
{
    return 0.25;
}

- (void)animateTransition:(id)transitionContext
{
    UIViewController* firstVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
    UIViewController* secondVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
    UIView* containerView = [transitionContext containerView];
    UIView* firstView = firstVC.view;
    UIView* secondView = secondVC.view;

    if (self.isPresenting) {
        [containerView addSubview:secondView];
        secondView.frame = (CGRect){
            containerView.frame.origin.x,
            containerView.frame.origin.y + containerView.frame.size.height,
            containerView.frame.size
        };

        firstView.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed;
        [UIView animateWithDuration:0.25 animations:^{
            secondView.frame = containerView.frame;
        } completion:^(BOOL finished) {
            [transitionContext completeTransition:YES];
        }];
        } else {
        [UIView animateWithDuration:0.25 animations:^{
            firstView.frame = (CGRect){
                containerView.frame.origin.x,
                containerView.frame.origin.y + containerView.frame.size.height,
                containerView.frame.size
        };

        } completion:^(BOOL finished) {
            [transitionContext completeTransition:YES];
        }];
    }
}

Esto hace una animación slide-in-from-the-bottom que imita la animación modal predeterminada, pero puede hacerla lo que quiera.

Lo importante es que la vista del controlador de vista que se presenta permanezca en la parte posterior, lo que le permite crear un efecto transparente.

Esta solución funciona para iOS 7 +

 3
Author: Pedro Mancheno,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-10-13 20:57:47

Una forma muy sencilla de hacer esto (usando Storyboards, por ejemplo) es:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"SomeStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"SomeStoryboardViewController"];
// the key for what you're looking to do:
vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
vc.view.alpha = 0.50f;

[self presentViewController:vc animated:YES completion:^{
    // great success
}];

Esto presentará un UIViewController en un Storyboard modalmente, pero con un fondo translúcido.

 3
Author: JaredH,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-01-14 16:19:38

Para recapitular todas las buenas respuestas y comentarios aquí y todavía tener una animación mientras se mueve a su nuevo ViewController esto es lo que hice: (Compatible con iOS 6 y arriba)

Si está usando un UINavigationController \ UITabBarController este es el camino a seguir:

    SomeViewController *vcThatWillBeDisplayed = [self.storyboard instantiateViewControllerWithIdentifier:@"SomeVC"];

    vcThatWillBeDisplayed.view.backgroundColor = [UIColor colorWithRed: 255/255.0 green:255/255.0 blue:255/255.0 alpha:0.50];    

    self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;
    [self presentViewController:presentedVC animated:YES completion:NULL];

Si lo haces perderás tu animación modalTransitionStyle. Para resolverlo, puede agregar fácilmente a su clase SomeViewController esto:

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [UIView animateWithDuration:0.4 animations:^() {self.view.alpha = 1;}
       completion:^(BOOL finished){}];
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.alpha = 0;
}
 2
Author: Segev,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-07-09 14:10:48

Trabajando para iOS 7-10

if #available(iOS 8.0, *) {
    nextVC.modalPresentationStyle = .OverCurrentContext
    self.presentViewController(nextVC, animated: true, completion: nil)
} else {
    // Fallback on earlier version
    self.modalPresentationStyle = .Custom          
    nextVC.modalTransitionStyle = .CrossDissolve            
    self.presentViewController(nextVC, animated: false, completion: nil)
    }
}
 2
Author: iluvatar_GR,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-03-15 12:47:53

La solución a esta respuesta usando swift sería la siguiente.

let vc = MyViewController()
vc.view.backgroundColor = UIColor.clear // or whatever color.
vc.modalPresentationStyle = .overCurrentContent
present(vc, animated: true, completion: nil)
 2
Author: Anthony Dito,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-07-06 16:21:39

Si está utilizando segue modal, asegúrese de configurarlo como esta imagen (puede desactivar la animación si lo desea) introduzca la descripción de la imagen aquí

 1
Author: Ahmed,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-12-17 05:20:33

Un método completo probado en iOS 7 e iOS 8.

@interface UIViewController (MBOverCurrentContextModalPresenting)

/// @warning Some method of viewControllerToPresent will called twice before iOS 8, e.g. viewWillAppear:.
- (void)MBOverCurrentContextPresentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion;

@end

@implementation UIViewController (MBOverCurrentContextModalPresenting)

- (void)MBOverCurrentContextPresentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {
    UIViewController *presentingVC = self;

    // iOS 8 before
    if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) {
        UIViewController *root = presentingVC;
        while (root.parentViewController) {
            root = root.parentViewController;
        }

        [presentingVC presentViewController:viewControllerToPresent animated:YES completion:^{
            [viewControllerToPresent dismissViewControllerAnimated:NO completion:^{
                UIModalPresentationStyle orginalStyle = root.modalPresentationStyle;
                if (orginalStyle != UIModalPresentationCurrentContext) {
                    root.modalPresentationStyle = UIModalPresentationCurrentContext;
                }
                [presentingVC presentViewController:viewControllerToPresent animated:NO completion:completion];
                if (orginalStyle != UIModalPresentationCurrentContext) {
                    root.modalPresentationStyle = orginalStyle;
                }
            }];
        }];
        return;
    }

    UIModalPresentationStyle orginalStyle = viewControllerToPresent.modalPresentationStyle;
    if (orginalStyle != UIModalPresentationOverCurrentContext) {
        viewControllerToPresent.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    }
    [presentingVC presentViewController:viewControllerToPresent animated:YES completion:completion];
    if (orginalStyle != UIModalPresentationOverCurrentContext) {
        viewControllerToPresent.modalPresentationStyle = orginalStyle;
    }
}

@end
 1
Author: BB9z,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-03-10 06:26:50

En appdelegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[_window rootViewController]setModalPresentationStyle:UIModalPresentationCurrentContext];
    return YES;
}

En su primer controlador de vista desde donde tiene que cargar la siguiente vista:

  NextViewController *customvc = [[NextViewController alloc]init];
    [self presentViewController:customvc animated:YES completion:^{

    }];

En su nextViewController que se agregará transparente:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor clearColor];
    UIView* backView = [[UIView alloc] initWithFrame:self.view.frame];
    backView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
    [self.view insertSubview:backView atIndex:0];
}
 0
Author: Zaraki,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-04-03 06:02:00

La pantalla de inicio de sesión es un modal, lo que significa que se encuentra en la parte superior de la pantalla anterior. Hasta ahora hemos desenfocado el Fondo, pero no está desenfocando nada; es solo un fondo gris.

Necesitamos establecer nuestro Modal correctamente.

Objetivo de enlace de imagen

  • Primero, necesitamos cambiar el fondo de vista del Controlador de vista a color claro. Simplemente significa que debe ser transparente. De forma predeterminada, esa vista es blanca.

  • En segundo lugar, necesidad de seleccionar el Segue que conduce a la pantalla de inicio de sesión, y en el Inspector de atributos, establecer la Presentación en el Contexto Actual. Esta opción solo está disponible con Diseño automático y Clases de tamaño habilitadas.

Objetivo de enlace de imagen

 0
Author: tinkl,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-04-15 07:05:50

Establecer la navegación modalPresentationStyle a UIModalPresentationCustom

Y establezca el color de fondo de su controlador de vista presentado como color claro.

 0
Author: ,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-07-05 08:28:31