2009-07-03 26 views
6

Estoy usando la animación flip para animar entre dos vistas en mi viewcontroller. El problema es que el fondo muestra un fondo blanco en blanco mientras se lleva a cabo la animación. Me gustaría mostrar un fondo negro.iPhone: las vistas que se abren muestran un fondo blanco

Intenté configurar el color de fondo de la vista principal en negro tanto en IB como en el código. Pero el fondo sigue siendo blanco.

¿Puede alguien ayudarme por favor.

Gracias.

Añadiendo el código

[self setContentView:[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]]; 
contentView.backgroundColor = [UIColor blackColor]; 
[contentView addSubview:toolbar]; 
[self setView:contentView]; 
[contentView release]; 

frontView = [[FrontView alloc] initWithFrame:viewFrame]; 
[frontView setViewController:self]; 
[self.view insertSubview:frontView belowSubview:toolbar]; 

//Initializing the back view here too 
//on button click, executing normal flip code 

Incluso después de esto me sale un fondo blanco

Respuesta

8

Creo que su problema podría ser que la ventana de UI se muestra durante la animación. Para solucionar este problema, establece el color de fondo de tu ventana principal. Puedes hacer esto en código o en IB.

0

Se empieza por la creación de una vista principal falso, y establecer su fondo a negro:

// Create the main view 
    UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; 
    contentView.backgroundColor = [UIColor blackColor]; 
    self.view = contentView; 
    [contentView release]; 

Luego, crea sus vistas frontal y posterior, y las agrega a su vista principal:

// create front and back views 
UIView *frontView = ... 
UIView *backView = ... 

Si está utilizando IB, omita el paso anterior y añadir directamente sus puntos de vista

// add the views 
    [self.view addSubview:backView]; 
    [self.view addSubview:frontView]; 

Ahora hacer la animación de imágenes cambiantes como de costumbre.

EDITAR: Probablemente no funcione porque en su código está agregando el frontView debajo de la barra de herramientas. Agregue primero la vista posterior, luego la vista frontal y finalmente la barra de herramientas usando el método addSubview :. A continuación, utilice el siguiente código para animar el flip:

- (IBAction) flipView{ 
    // Start Animation Block 
    CGContextRef context = UIGraphicsGetCurrentContext(); 
    [UIView beginAnimations:nil context:context]; 
    [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES]; 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
    [UIView setAnimationDuration:1.0]; 

    // Animations 
    [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1]; 

    // Commit Animation Block 
    [UIView commitAnimations]; 

} 

Puesto que el código realiza [self.view exchangeSubviewAtIndex: 0 withSubviewAtIndex: 1]; el orden en que agrega las subvistas es relevante.

+0

Gracias. No puedo conseguir que funcione. publicando el código en la pregunta – lostInTransit

Cuestiones relacionadas