UIView animation

前端 未结 5 2043
醉话见心
醉话见心 2020-12-30 18:00

I am trying to animate a UIView here. It looks like a rectangle, and I just want to translate it to my coordinations.

So, how can I animate it? I tried

相关标签:
5条回答
  • 2020-12-30 18:24

    Use "QuartzCore.framework" With these animations.

    -(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];
    }
    
    0 讨论(0)
  • 2020-12-30 18:34

    In iOS 4, the UIView block animation method is easiest:

    [UIView animateWithDuration:1.0 animations:^{
        myView.frame = myNewFrameRect;
    }];
    

    http://developer.apple.com/library/ios/documentation/uikit/reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/clm/UIView/animateWithDuration:animations:

    0 讨论(0)
  • 2020-12-30 18:39
    //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];
    }
    
    0 讨论(0)
  • 2020-12-30 18:48

    Here is an example of animating a view to move off screen. You should be able to slightly adjust it for your needs:

    
    [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];
    
    0 讨论(0)
  • 2020-12-30 18:48
    [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];
    

    Working Fine definitely.

    0 讨论(0)
提交回复
热议问题