• UIKit Animation


    UIKit Animation


    1.属性动画

    - (void)changeFrameAnimation {
    [UIView beginAnimations:@"frameAnimation" context:nil];
    [UIView setAnimationDuration:0.8];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationWillStartSelector:@selector(startAnimation:)];
    [UIView setAnimationDidStopSelector:@selector(stopAnimation:)];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    [UIView setAnimationRepeatCount:1];

    // [UIView setAnimationRepeatAutoreverses:YES];

    self.secondView.frame = self.firstView.frame;

    [UIView commitAnimations];
    }

    2.Transition 提供了一个图层变化的过渡效果,它能影响图层的整个内容

    - (void)transitionAnimation {
    [UIView beginAnimations:@"frameAnimation" context:nil];
    [UIView setAnimationDuration:0.8];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationWillStartSelector:@selector(startAnimation:)];
    [UIView setAnimationDidStopSelector:@selector(stopAnimation:)];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];

    [UIView setAnimationRepeatCount:1];

    self.firstView.backgroundColor = [UIColor purpleColor];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.firstView cache:YES]; // 转场效果,forView 动画作用对象

    [UIView commitAnimations];
    }
    1. Block Animation
    - (void)block1 {
    [UIView animateWithDuration:0.8 animations:^{
    self.secondView.frame = self.firstView.frame;
    }];
    }

    - (void)block2 {
    [UIView animateWithDuration:0.8 animations:^{
    self.secondView.frame = self.firstView.frame;
    } completion:^(BOOL finished) {
    NSLog(@"complete blockAnimation");
    }];
    }

    - (void)block3 {
    [UIView animateWithDuration:0.8 delay:3.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
    self.secondView.frame = self.firstView.frame;
    } completion:^(BOOL finished) {
    NSLog(@"options");
    }];
    }

    4.SpringAnimation

    /**
    * @author Jack Lee, 16-05-16 15:05:05
    *
    * @brief after iOS7.0
    */

    - (void)springAnimation {
    // damping:取值范围0~1,值越小振荡越明显
    // velocity:初始速度,越大越快
    [UIView animateWithDuration:0.8 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:10 options:UIViewAnimationOptionCurveLinear animations:^{
    self.secondView.frame = self.firstView.frame;
    } completion:^(BOOL finished) {
    NSLog(@"complete spring");
    }];
    }

    5.关键帧动画

    /**
    * @author Jack Lee, 16-05-16 15:05:00
    *
    * @brief after iOS7.0
    */

    - (void)keyFrameAnimation {
    [UIView animateKeyframesWithDuration:4 delay:0 options:UIViewKeyframeAnimationOptionCalculationModeLinear animations:^{
    [UIView addKeyframeWithRelativeStartTime:0 relativeDuration:1 animations:^{
    self.firstView.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:1];
    }];

    [UIView addKeyframeWithRelativeStartTime:1 relativeDuration:1 animations:^{
    self.firstView.backgroundColor = [UIColor colorWithRed:0.8 green:0.6 blue:0.6 alpha:1];
    }];

    [UIView addKeyframeWithRelativeStartTime:2 relativeDuration:1 animations:^{
    self.firstView.backgroundColor = [UIColor colorWithRed:0.8 green:0.4 blue:0.4 alpha:1];
    }];

    [UIView addKeyframeWithRelativeStartTime:3 relativeDuration:1 animations:^{
    self.firstView.backgroundColor = [UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:1];
    }];

    } completion:^(BOOL finished) {
    NSLog(@"complete keyframe animation");
    }];
    }
    1. Transition过渡动画二
    - (void)block3 {
    [UIView transitionWithView:self.firstView duration:0.8 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{
    self.firstView.backgroundColor = [UIColor colorWithRed:0.2 green:0.5 blue:0.7 alpha:1];
    } completion:^(BOOL finished) {
    NSLog(@"complete block3");
    }];
    }

    - (void)block4 {
    UILabel *l = [[UILabel alloc] initWithFrame:self.firstView.frame];
    l.font = [UIFont systemFontOfSize:30];
    l.textColor = [UIColor orangeColor];
    l.textAlignment = NSTextAlignmentCenter;
    l.text = @"翻转";

    [UIView transitionFromView:self.firstView toView:l duration:0.8 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {
    NSLog(@"from to complete");
    }];

    }
     
  • 相关阅读:
    IIS 7.0 下 httpMoudle 失效的问题
    iis 管理员执行 aspnet_iis.exe
    java script 闭包
    c# 多语言实现 与 InitializeCulture
    谈 IIS7.5 Asp.Net模拟用户
    oledb 写入 office2010 以及发布到iis 遇到的奇怪问题总结
    DataTableToExcel
    下拉加载数据
    简单使用TFS管理源代码
    a span做成按钮样式不选中文字
  • 原文地址:https://www.cnblogs.com/buakaw/p/5725674.html
Copyright © 2020-2023  润新知