zoukankan      html  css  js  c++  java
  • 控件基本动画

     1 #import "BasicViewController.h"
     2 
     3 @interface BasicViewController ()
     4 //用来测试动画效果的一个视图
     5 @property (weak, nonatomic) IBOutlet UIView *testView;
     6 
     7 @end
     8 
     9 @implementation BasicViewController
    10 
    11 - (void)viewDidLoad {
    12     [super viewDidLoad];
    13     
    14     
    15 }
    16 #pragma mark - 动态的改变frame
    17 - (IBAction)changeFrameAction:(UIButton *)sender {
    18    //UIView动画起始于beginAnimation终止于commitAnimation
    19     //第一步:开始设置UIView动画
    20     [UIView beginAnimations:@"move" context:nil];
    21     //第二步:设置播放时长
    22     [UIView setAnimationDuration:2];
    23     //第三步:设置UIView回调的对象(即代理)
    24     [UIView setAnimationDelegate:self];
    25     //第四步:设置要改变的内容
    26     self.testView.frame = CGRectMake(100, 100, 200, 100);
    27     //第五步:提交动画效果
    28     [UIView commitAnimations];
    29     
    30     
    31 }
    32 - (IBAction)changeColor:(UIButton *)sender {
    33     [UIView beginAnimations:@"颜色" context:nil];
    34     [UIView setAnimationDuration:2];
    35     [UIView setAnimationDelegate:self];
    36     self.testView.backgroundColor = [UIColor magentaColor];
    37     [UIView commitAnimations];
    38 }
    39 - (IBAction)changeAlpha:(UIButton *)sender {
    40     [UIView beginAnimations:@"alpha" context:nil];
    41     [UIView setAnimationDuration:2];
    42     [UIView setAnimationDelegate:self];
    43     self.testView.alpha = 0.5;
    44     [UIView commitAnimations];
    45 }
    46 - (IBAction)changeBounds:(UIButton *)sender {
    47     [UIView beginAnimations:@"bounds" context:nil];
    48     [UIView setAnimationDuration:2];
    49     [UIView setAnimationDelegate:self];
    50     self.testView.bounds = CGRectMake(30, 40, 100, 100);
    51     [UIView commitAnimations];
    52 }
    53 //仿射翻转
    54 - (IBAction)totationAction:(UIButton *)sender {
    55     //第一步:开始动画
    56     [UIView beginAnimations:@"仿射翻转" context:nil];
    57     //第二步:设置时长
    58     [UIView setAnimationDuration:3];
    59     //第三步:设置淡入的效果
    60     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    61     //第四步:设置代理
    62     [UIView setAnimationDelegate:self];
    63     //第五步:设置翻转的方向
    64     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.testView cache:YES];
    65     //第六步:提交
    66     [UIView commitAnimations];
    67     
    68 }
    69 - (IBAction)transformAction:(UIButton *)sender {
    70     [UIView beginAnimations:@"仿射旋转" context:nil];
    71     [UIView setAnimationDuration:3];
    72     [UIView setAnimationDelegate:self];
    73     //设置旋转的度数
    74     CGAffineTransform transform = CGAffineTransformMakeRotation(3 * M_PI);
    75     //设置旋转对象
    76     [self.testView setTransform:transform];
    77     [UIView commitAnimations];
    78 }
    79 
    80 #pragma mark - UIViewAnimation的代理方法
    81 -(void)animationWillStart:(NSString *)animationID context:(void *)context
    82 {
    83     NSLog(@"animationID = %@,context = %@",animationID,context);
    84 }
    85 
    86 -(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
    87 {
    88     NSLog(@"animationID = %@,context = %@",animationID,context);
    89 }
  • 相关阅读:
    从零开始搭建系统1.2——Nginx安装及配置
    从零开始搭建系统1.1——CentOs安装
    从零开始搭框架——系统架构
    从零开始搭建系统——前言
    PHP语法入门以及变量
    用PHP写出计算器
    PHP常量以及基本数据类型
    PHP入门了解
    php中搭建Web服务器和服务器配置
    JS中for,for...in,for...of以及foreach循环的用法
  • 原文地址:https://www.cnblogs.com/DevinSMR/p/5342626.html
Copyright © 2011-2022 走看看