Mostrando elemento de interfaz de usuario con animación en iPhone

Is there a way to do the following without an instant hide/unhide? Or do I have to make everything a separate view or something complicated? A simple fade in fade out like the modal transition style is all I'm looking for.

-(IBAction)someMethod
{
    UIButton.hidden = NO;
    tableView.hidden = NO;
}

-(void)viewDidLoad
{
    UIbutton.hidden = YES;
    tableView.hidden = YES;
}

preguntado el 09 de marzo de 12 a las 16:03

2 Respuestas

   [UIView animateWithDuration:2.0f
                     animations:^ {
UIButton.alpha = 1;
 UIButton.hidden = NO;
tableView.alpha = 1
    tableView.hidden = NO;
                     }];

Do the opposite for hide and change the duration to your need.

respondido 09 mar '12, 16:03

You could animate the alpha value:

[UIView animateWithDuration:0.5f animations:^{
    button.alpha = 0.0f;
    tableView.alpha = 0.0f;
}];

and it's counterpart

[UIView animateWithDuration:0.5f animations:^{
    button.alpha = 1.0f;
    tableView.alpha = 1.0f;
}];

respondido 09 mar '12, 16:03

Does animate the entire view or just the UIElements? - Eric

Just the elements inside the block. I edited my post to make it more clear. - Tim

can someone explain the ^ symbol programmatically? What is that saying? - Eric

It's called a block - a piece of code that get's executed. Think of it as an anonymous function. Here's the Apple Doc: desarrollador.apple.com/library/ios/#documentation/cocoa/Conceptual/… - Tim

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.