美文网首页
UIView 动画总结

UIView 动画总结

作者: Damoness | 来源:发表于2017-11-19 09:40 被阅读0次

UIViewAnimation

这是最基本的动画

- (void)startAnimating{
    
                                                  //__bridge 不移交控制权
    [UIView beginAnimations:@"animation" context:(__bridge void *)(self)];
    
    [UIView setAnimationDuration:0.4];
    _square.center = CGPointMake(_square.center.x + 100, _square.center.y);
    [UIView setAnimationDelegate:self];
    
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
    [UIView commitAnimations];
    
}

UIViewAnimationWithBlocks

对基本UIViewAnimation的block封装

- (void)startBlockAnimation{

    UIViewAnimationOptions options = UIViewAnimationOptionAutoreverse | UIViewAnimationOptionTransitionCrossDissolve ;
    
    [UIView animateWithDuration:0.4 delay:0 options:options animations:^{
        
        _square.center = CGPointMake(_square.center.x + 100, _square.center.y);
        
    } completion:^(BOOL finished) {
        
    }];
    
    
}

+ (void)transitionWithView:(UIView *)view duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^ __nullable)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0); //翻转动画

UIViewKeyframeAnimations

设置动画里面的几个关键帧, 系统自动构建出完整的动画


//实现_square 按正方形规矩运动
- (void)startKeyFrameAnimation{
    
    UIViewKeyframeAnimationOptions options = UIViewKeyframeAnimationOptionRepeat;
    
    [UIView animateKeyframesWithDuration:4 delay:0 options:options animations:^{
        
        
        double frameDuration = 1.0 / 4;
        
        [UIView addKeyframeWithRelativeStartTime:0 relativeDuration:frameDuration animations:^{
            
            _square.center = CGPointMake(_square.center.x + 100, _square.center.y);
            
        }];
        
        [UIView addKeyframeWithRelativeStartTime:frameDuration  relativeDuration:frameDuration animations:^{
            
            _square.center = CGPointMake(_square.center.x , _square.center.y + 100);
            
        }];
        
        [UIView addKeyframeWithRelativeStartTime:frameDuration * 2 relativeDuration:frameDuration animations:^{
            
            _square.center = CGPointMake(_square.center.x - 100, _square.center.y);
            
        }];
        
        [UIView addKeyframeWithRelativeStartTime:frameDuration * 3 relativeDuration:frameDuration animations:^{
            
            _square.center = CGPointMake(_square.center.x , _square.center.y -100);
            
        }];
        
        
        
    } completion:nil];
    
    
}

相关文章

  • UIView动画UIView Animation总结

    UIView动画UIView Animation总结 原文地址 基本动画 最常用的几种方式 animati...

  • 动画(一)

    简单的总结下自己学习动画的知识: 对于UIview的动画 [UIView animateWithDuration:...

  • iOS-UIView动画-UIView Animation简介

    UIView Animation动画是iOS开发中最常用的动画类,下面总结一下UIView Animation动画...

  • 位移动画

    动画基础总结篇UIView Animations

  • UIView Animation

    今天总结一下UIView动画就是 UiView动画是基于高层API封装进行封装的,对UIView的属性进行修改时候...

  • 动画案例:加入购物车

    UIView 动画 CALay 动画 UIView 动画: UIView 动画:UIView的属性动画 就是在一定...

  • UIView 动画总结

    UIViewAnimation 这是最基本的动画 UIViewAnimationWithBlocks 对基本UIV...

  • iOS 动画

    UIView基础动画实现方式一 UIView位置大小动画UIView颜色动画UIView透明度动画 UIView基...

  • iOS动画总结(收集)

    iOS动画 1.iOS动画专题·UIView二维形变动画与CAAnimation核心动画 2.iOS动画总结(Co...

  • ios 动画总结(未完)

    针对iOS 动画做一下总结 基本动画 帧动画 组动画 转场动画 !- - !插一句UIview代码块(能实现最简...

网友评论

      本文标题:UIView 动画总结

      本文链接:https://www.haomeiwen.com/subject/gwduvxtx.html