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

  • 相关阅读:
    CSU1256 天朝的单行道(spfa)
    WordPress For SAE进入后台
    Android studio 使用NDK工具实现JNI编程
    android动画具体解释一 概述
    VC6.0编译DLL,使用VS2010调用问题及解决方法
    android 地址控件概述
    android 多线程概述
    android 中的 window,view,activity具体关系
    比较windows phone程序启动和android程序启动原理
    比较windows phone 的回退事件与android的回退事件
  • 原文地址:https://www.cnblogs.com/Mr-zyh/p/5510323.html
Copyright © 2011-2022 走看看