动画

本文深入探讨了iOS中各种动画效果的实现方式,包括UIView动画、关键帧动画、CATransition及CABasicAnimation等,并提供了丰富的代码示例。
#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIView *redView;
@property (weak, nonatomic) IBOutlet UIImageView *imageV;
@property (weak, nonatomic) IBOutlet UIImageView *headerImageV;
@property (weak, nonatomic) IBOutlet UIImageView *footImageView;
@property (weak, nonatomic) IBOutlet UIImageView *buleImageView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

}

//动画
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
   /* //UIView动画
    //1.不带结束block的动画
//    [UIView animateWithDuration:2 animations:^{
//        _redView.frame = CGRectMake(10, 500, 133, 96);
//    }];
    //2.带结束block的动画
    //渐变效果
    [UIView animateWithDuration:2 animations:^{
        _redView.frame = CGRectMake(10, 500, 133, 96);
        _redView.alpha = 0;
    } completion:^(BOOL finished) {

        [UIView animateWithDuration:2 animations:^{
            //在带结束block里面嵌套一个不带结束block的动画
            _redView.frame = CGRectMake(12, 15, 133, 96);
            _redView.alpha = 1;

        }];
    }];
    */
    //阻尼
    //弹簧效果 initialSpringVelocity:似乎是力度,不太清楚这个
//    [UIView animateWithDuration:2 delay:0 usingSpringWithDamping:0.05 initialSpringVelocity:100000 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
//        _redView.frame = CGRectMake(12, 15, 133, 97);
//    } completion:^(BOOL finished) {
//        
//    }];

    /*
    //UIView帧动画(可以做一个移动的动画)
    [UIView animateKeyframesWithDuration:6 delay:0 options:UIViewKeyframeAnimationOptionCalculationModeLinear animations:^{
        [UIView addKeyframeWithRelativeStartTime:0 relativeDuration:1/3.0 animations:^{
            _redView.frame = CGRectMake(100, 100, 100, 100);
        }];
        [UIView addKeyframeWithRelativeStartTime:1/3.0 relativeDuration:1/3.0 animations:^{
            _redView.frame = CGRectMake(100, 400, 100, 100);
        }];

        [UIView addKeyframeWithRelativeStartTime:2/3.0 relativeDuration:1/3.0 animations:^{
            _redView.frame = CGRectMake(200, 30, 100, 100);
        }];
    } completion:^(BOOL finished) {

    }];
     */

    /*
    //UIView的原始写法
    [UIView beginAnimations:@"原始动画" context:nil];
    //动画持续时间
    [UIView setAnimationDuration:1];
    [UIView setAnimationRepeatCount:5];//重复次数
    _redView.frame = CGRectMake(12, 200, 133, 96);
    //要签协议
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(animationStop)];
    [UIView commitAnimations];//提交动画
     */


   /*
    //layer动画 要有协议
    CATransition *animation1 = [CATransition animation];
    //设置时间
    animation1.duration = 2;
    //设置次数
    animation1.repeatCount = 2;//(无限重复)
    //设置动画样式
//    animation1.type = @"rippleEffect";//波纹效果
    //    animation.type = @"cube"; //旋转
    //    animation.type = @"suckEffect";
    //    animation.type = @"oglFlip";
        animation1.type = @"rippleEffect";//波纹
    //    animation.type = @"pageCurl";//页撕开
    //    animation.type = @"pageUnCurl";//页粘贴
    //    animation.type = @"cameraIrisHollowOpen";//摄像机打开
    //    animation.type = @"cameraIrisHollowClose";//摄像机关闭
    //字样式
    animation1.subtype = kCATransitionFromRight;
    //获取动画结束 为了确定停止
    [animation1 setDelegate:self];
    [animation1 setValue:@"美女波动" forKey:@"bodong"];
    //添加动画
    [_imageV.layer addAnimation:animation1 forKey:nil];
  */


    /*
    //旋转动画(平面的)
    //Basic:基础 rotaion:旋转
    CABasicAnimation *basicAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    basicAnimation.duration = 2;
    basicAnimation.repeatCount = MAXFLOAT;
    basicAnimation.fromValue = [NSNumber numberWithInt:1];
    basicAnimation.toValue = [NSNumber numberWithInt:M_PI*10];
    [_headerImageV.layer addAnimation:basicAnimation forKey:@"rotation"];
//    [_footImageView.layer addAnimation:basicAnimation forKey:@"rotaion"];

    //缩放效果(动心效果)
    CABasicAnimation *basesicAnimation1 = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    basesicAnimation1.duration = 0.01;
    basesicAnimation1.repeatCount = MAXFLOAT;
    basesicAnimation1.fromValue = [NSNumber numberWithFloat:0.5];
    //放大的倍数
    basesicAnimation1.toValue = [NSNumber numberWithFloat:2];
    [_imageV.layer addAnimation:basesicAnimation1 forKey:@"scale"];
    [_imageV.layer addAnimation:basicAnimation forKey:@"rotation"];
    */

    //transform
    [UIView animateWithDuration:2 animations:^{
      //make 移动一次
//        _buleImageView.transform = CGAffineTransformMakeTranslation(100, 100);
//        //不带make连续移动
//        _buleImageView.transform = CGAffineTransformTranslate(_buleImageView.transform, 100, 100);
//        _buleImageView.transform = CGAffineTransformRotate(_buleImageView.transform, M_PI_4);

//        //带make的旋转:只执行一次
//        _buleImageView.transform = CGAffineTransformMakeRotation(M_PI_4);
        //缩放(带make)
//        _buleImageView.transform = CGAffineTransformScale(_buleImageView.transform, 2, 0.5);
        //3D效果的旋转
//        _buleImageView.layer.transform  = CATransform3DRotate(_buleImageView.layer.transform, M_PI_4, 0, 1, 0);


        //关键帧动画 position:位置
        CAKeyframeAnimation *keyframeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
        CGMutablePathRef path  = CGPathCreateMutable();
        CGPathMoveToPoint(path, NULL, _buleImageView.center.x, _buleImageView.center.y);
        //依次添加每个点,让其移动
        CGPathAddLineToPoint(path, NULL, 100, 100);
        CGPathAddLineToPoint(path, NULL, 100, 200);
        CGPathAddLineToPoint(path, NULL, 200, 100);
        CGPathAddLineToPoint(path, NULL, 300, 400);

        //添加路径
        [keyframeAnimation setPath:path];
        //设置时间
        [keyframeAnimation setDuration:10];
        //设置次数 重复次数
        [keyframeAnimation setRepeatCount:10];
        [_buleImageView.layer addAnimation:keyframeAnimation forKey:@"position"];




    }];


}

-(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
    NSString *str = [anim valueForKey:@"bodong"];
    if ([str isEqualToString:@"美女波动"]) {
        NSLog(@"结束");
    }
}
-(void)animationStop
{
    NSLog(@"动画结束");
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
多源数据接入 支持校园各业务系统数据接入:包括教务系统(学生成绩、课程信息)、学工系统(奖惩记录、资助信息)、后勤系统(宿舍分配、能耗数据)、图书馆系统(借阅记录、馆藏信息)、一卡通系统(消费数据、门禁记录)等。 接入方式:提供数据库直连(MySQL、SQL Server)、文件导入(CSV、Excel、JSON)、API 接口调用等多种方式,支持实时同步与定时批量同步。 数据标准化与治理 建立校园数据标准体系:统一数据格式(如日期格式、学号编码规则)、定义核心数据元(如 “学生” 包含学号、姓名、专业等必选字段)、规范代码集(如性别代码 “1 - 男,2 - 女”)。 数据清洗:自动检测并处理缺失值、重复值、异常值(如成绩 > 100 分),通过规则引擎实现数据校验(如 “学生年龄需在 16-30 岁之间”)。 元数据管理:记录数据来源、格式、更新频率、负责人等信息,生成数据血缘图谱,追踪数据从产生到应用的全生命周期。 二、数据共享与交换核心功能 分布式数据存储 基于 Hadoop HDFS 实现海量数据存储:结构化数据(成绩、消费记录)存入 HBase,非结构化数据(文档、图片、视频)直接存储于 HDFS,日志类数据通过 Flume 采集至 HDFS。 支持数据分片与副本机制,确保数据高可用(默认 3 副本存储),满足校园 PB 级数据存储需求。 数据交换引擎 构建点对点数据交换通道:各部门系统可通过交换引擎向平台上传数据或申请获取授权数据,支持同步 / 异步交换模式。 交换流程管理:定义数据交换规则(如 “学工系统每日向平台同步新增学生信息”),记录交换日志(成功 / 失败状态、数据量),失败时自动重试。 数据脱敏:对敏感数据(如身份证号、银行卡号)在交换过程中进行脱敏处理(如显示 “110********5678”),兼顾共享与隐私保护。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值