zoukankan      html  css  js  c++  java
  • 动画效果-基础动画设置(改变大小,改变透明度,翻转,旋转,复原)

    在可视化编程下

    #import "BaseViewController.h"

    @interface BaseViewController ()

    @property (weak, nonatomic) IBOutlet UIImageView *imageView;

    @end

    @implementation BaseViewController

    - (void)viewDidLoad {

        [super viewDidLoad];

    }

    - (void)didReceiveMemoryWarning {

        [super didReceiveMemoryWarning];

    }

    // 改变大小

    - (IBAction)changeSizeAction:(UIButton *)sender {

        // 开始设置动画

        [UIView beginAnimations:@"size" context:nil];

        // 动画时长

        [UIView setAnimationDuration:2];

        // 改变后的图片大小

        self.imageView.frame = CGRectMake(50, 80, 200, 200);

        // 提交动画,开始播放动画

        [UIView commitAnimations];

    }

    // 改变透明度

    - (IBAction)changeAlpha:(UIButton *)sender {

        [UIView beginAnimations:@"alpha" context:nil];

        [UIView setAnimationDuration:2];

        self.imageView.alpha = 0.5;

        // 改变背景颜色

        self.imageView.backgroundColor = [UIColor cyanColor];

        [UIView commitAnimations];

    }

    // 翻转

    - (IBAction)overturnAction:(UIButton *)sender {

        // 开始设置动画

        [UIView beginAnimations:@"fanzhuan" context:nil];

        // 动画时长

        [UIView setAnimationDuration:2];

        // 设置翻转

        [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.imageView cache:YES];

        // 提交动画,开始播放动画

        [UIView commitAnimations];

    }

    // 旋转

    - (IBAction)xuanzhuanAction:(UIButton *)sender {

        // 开始设置动画

        [UIView beginAnimations:@"xuanzhuan" context:nil];

        // 动画时长

        [UIView setAnimationDuration:2];

        // 设置旋转角度

        // 参数1:当前的transform  参数2:旋转弧度

        CGAffineTransform transform = CGAffineTransformRotate(self.imageView.transform, M_PI_2);

        // 设置旋转

        [self.imageView setTransform:transform];

        // 提交动画,开始播放动画

        [UIView commitAnimations];

    }

    // 复原

    - (IBAction)fuyuanAction:(UIButton *)sender {

        // 开始设置动画

        [UIView beginAnimations:@"xuanzhuan" context:nil];

        // 动画时长

        [UIView setAnimationDuration:2];

        // 设置旋转角度(0度和180度不变,其它值相反)

        // 参数1:当前的transform  参数2:旋转弧度

        CGAffineTransform transform = CGAffineTransformInvert(self.imageView.transform);

        // 设置旋转

        [self.imageView setTransform:transform];

        // 提交动画,开始播放动画

        [UIView commitAnimations];

    }

    /*

    #pragma mark - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

        // Get the new view controller using [segue destinationViewController].

        // Pass the selected object to the new view controller.

    }

    */

    @end

  • 相关阅读:
    室内设计师招募中...
    winform控件部署于web中控件装载ie中
    Oracle10g在windows2003下双机热备安装
    购房风波(4)不了了之
    [原创]面向对象理解·抽象类和派生类理解和使用
    Infragistics NetAdvantage 2006 Volume 2 CLR 2.0曲折安装
    两个Javascript小tip
    PHP学习笔记之二
    C#开发语音机项目
    关于WebBrowser的DocumentText
  • 原文地址:https://www.cnblogs.com/Mr-zyh/p/5510323.html
Copyright © 2011-2022 走看看