UIView animación

Estoy tratando de animar un UIView aquí. Se parece a un rectángulo, y sólo quiero traducir a mi coordinaciones.

Así, ¿cómo puedo animar? Traté de encontrar algunos tutoriales, pero sin éxito.

InformationsquelleAutor Lucas Veiga | 2010-11-11

5 Kommentare

  1. 15

    Aquí es un ejemplo de la animación de una vista a mover fuera de la pantalla. Usted debe ser capaz de a poco se ajuste a sus necesidades:

    
    [UIView beginAnimations:@"bucketsOff" context:nil];
    [UIView setAnimationDuration:0.4];
    [UIView setAnimationDelegate:self];
    //position off screen
    [bucketView setCenter:CGPointMake(-160, 377)];
    [UIView setAnimationDidStopSelector:@selector(finishAnimation:finished:context:)];
    //animate off screen
    [UIView commitAnimations];
    • No hubo suerte. Me declarando la ‘myView’ en el archivo de encabezado. Lo he puesto en viewDidLoad como [myView setCenter:CGPointMake(-160, 377)];
    • Si se declara una línea fuera de un bloque de animación, no tendrá ningún efecto sobre la animación alguna.
    • Esto funciona si lo pones dentro de viewWillAppear. También es compatible diseño automático, lo que significa que tenía un cuadro de centrado vertical y horizontalmente, pero cambiando el centro funcionó a la perfección para animarlo.
  2. 4
    //try this AnimationTransitionCurlDown \UP
    
    -(void)pageDown
    {
     [UIView beginAnimations:nil context:NULL];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self cache:YES];
    
            [UIView commitAnimations];
    }
    
    -(void)pageUP
    {
    [UIView beginAnimations:nil context:NULL];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self cache:YES];
    
            [UIView commitAnimations];
    }
    
    //flip uiviews  using animation
    
    
    
    -(void)FlipFromLeft
    {
    [UIView beginAnimations:nil context:NULL];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self cache:YES];
    
            [UIView commitAnimations];
    }
    
    -(void)FlipFromRight
    {
    [UIView beginAnimations:nil context:NULL];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self cache:YES];
    
            [UIView commitAnimations];
    }
  3. 4

    Uso «QuartzCore.marco»
    Con estas animaciones.

    -(void)viewSlideInFromRightToLeft:(UIView *)views
    {
        CATransition *transition = nil;
        transition = [CATransition animation];
        transition.duration = 0.5;//kAnimationDuration
        transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        transition.type = kCATransitionPush;
        transition.subtype =kCATransitionFromRight;
        transition.delegate = self;
        [views.layer addAnimation:transition forKey:nil];
    }
    
    -(void)viewSlideInFromLeftToRight:(UIView *)views
    {
        CATransition *transition = nil;
        transition = [CATransition animation];
        transition.duration = 0.5;//kAnimationDuration
        transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        transition.type = kCATransitionPush;
        transition.subtype =kCATransitionFromLeft;
        transition.delegate = self;
        [views.layer addAnimation:transition forKey:nil];
    }
    
    -(void)viewSlideInFromTopToBottom:(UIView *)views
    {
        CATransition *transition = nil;
        transition = [CATransition animation];
        transition.duration = 0.5;//kAnimationDuration
        transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        transition.type = kCATransitionPush;
        transition.subtype =kCATransitionFromBottom ;
        transition.delegate = self;
        [views.layer addAnimation:transition forKey:nil];
    }
    
    -(void)viewSlideInFromBottomToTop:(UIView *)views
    {
        CATransition *transition = nil;
        transition = [CATransition animation];
        transition.duration = 0.5;//kAnimationDuration
        transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        transition.type = kCATransitionPush;
        transition.subtype =kCATransitionFromTop ;
        transition.delegate = self;
        [views.layer addAnimation:transition forKey:nil];
    }
    • Para AnimationSubType puede utilizar la siguiente opción:-> kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
    • Para AnimationType puede utilizar la siguiente opción:-> kCATransitionMoveIn, kCATransitionPush, kCATransitionReveal, kCATransitionFade
  4. 0
    [UIView beginAnimations:@"your text" context:nil];
    [UIView setAnimationDuration:0.4]; //Your animation duration
    [UIView setAnimationDelegate:self];
    //
    write your code here , what you want to animate
    //
    [UIView commitAnimations];

    Trabajando bien definitivamente.

Kommentieren Sie den Artikel

Bitte geben Sie Ihren Kommentar ein!
Bitte geben Sie hier Ihren Namen ein

Pruebas en línea