UI Animation 动画效果

Animation的基本实现功能:
首先创建一个简单的button 在button方法中来实现不同的动画效果:
- (void)buttonClicked:(UIButton *)button
{
    // UIView 动画
    // 1.最简单的动画实现
    // 参数1:动画执行一次需要的时间
    // 参数2:动画执行的内容(写动画执行的结果)
//    [UIView animateWithDuration:10.0 animations:^{
//        button.alpha = 0.38;
//        button.backgroundColor = [UIColor blueColor];
//        button.frame = CGRectMake(0, 0, 320, 100);
//    }];
    
    
    
    
    // 参数3:动画执行结束后 要执行的代码
//    [UIView animateWithDuration:1.f animations:^{
//        
//        // 对动画本身设置
//        
//        // 可以给动画一个还原效果
//        [UIView setAnimationRepeatAutoreverses:YES];
//        // 动画重复的次数
//        [UIView setAnimationRepeatCount:1.25];
//        // 动画延迟几秒执行
//       // [UIView setAnimationDelay:1.0];
//        // 动画运行的速度曲线
//        [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
//        
//        button.backgroundColor = [UIColor blueColor];
//        button.bounds = CGRectMake(0, 0, 200, 200);
//    } completion:^(BOOL finished) {
//        NSLog(@"动画完毕");
//    }];
    
    
    
    // 3.
    
    // 参数3:动画的选项 在这里一般写 速度曲线
//    [UIView animateKeyframesWithDuration:1.f delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
//        button.frame = CGRectMake(0, 0, 200, 200);
//    } completion:nil];
    
    
    
    //4.
    
//    [UIView animateWithDuration:1.f delay:0 usingSpringWithDamping:0.05 initialSpringVelocity:0.4 options:UIViewAnimationOptionCurveEaseIn animations:^{
//        button.frame = CGRectMake(0, 0, 200, 200);
//    } completion:nil];

    
    
    // transition动画
    
//    [UIView transitionWithView:button duration:1.f options:UIViewAnimationOptionTransitionCurlDown animations:^{
//        button.frame = CGRectMake(0, 0, 200, 200);
//    } completion:nil];
    
    
    
    // 把第一个视图移除 把第二个视图 添加到父视图上
    
//    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
//    view.backgroundColor = [UIColor blueColor];
//    // 参数1;要移除的view
//    // 参数2:要添加的view
//    [UIView transitionFromView:button toView:view duration:1.f options:UIViewAnimationOptionTransitionCurlUp completion:^(BOOL finished) {
//    
//    }];
    
    
    
    // CAAnimation layer层动画
    
    // CAPropertyAnimation 是一个抽象类
    // 1. CABasicAnimation 的使用
    
//    CABasicAnimation *animation1 = [CABasicAnimation animationWithKeyPath:@"transform.scale.y"];
//    // 从什么状态开始放大
//    animation1.fromValue = [NSNumber numberWithInt:1];
//    // 到什么状态结束
//    animation1.toValue = [NSNumber numberWithInt:3];
//    // 动画执行的时间
//    animation1.duration = 1.f;
//    // 是否有一个恢复
//    animation1.autoreverses = YES;
//    animation1.repeatCount = NSIntegerMax;
//    
//    
//    CABasicAnimation *animation2 = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
//    
//    // 从什么状态开始放大
//    animation2.fromValue = [NSNumber numberWithInt:1];
//    // 到什么状态结束
//    animation2.toValue = [NSNumber numberWithInt:M_PI * 2];
//    // 动画执行的时间
//    animation2.duration = 2.f;
//    // 是否有一个恢复
    animation2.autoreverses = YES;
//    animation2.repeatCount = NSIntegerMax;
//    
//    
//    
//    // 组动画 将几个动画组合到一起 同时执行
//    
//    CAAnimationGroup *group = [CAAnimationGroup animation];
//    group.animations = @[animation1,animation2];
//    // 将动画 添加到组动画之后 每个动画自己的设置将失效
//    group.duration = 3.f;
//    group.autoreverses = YES;
//    group.repeatCount = NSIntegerMax;
//    
//    [button.layer addAnimation:group forKey:@"111"];
//    
//    
//    
//    [button.layer addAnimation:animation2 forKey:@"111"];
    
    
    
    
//    // 关键帧动画
//    CAKeyframeAnimation *keyFrameAni = [CAKeyframeAnimation animationWithKeyPath:@"position"];
//    
//    // 产生一个路径
//    CGMutablePathRef path = CGPathCreateMutable();
//    // 设定一个初始点
//    CGPathMoveToPoint(path, nil, 100, 100);
//    
//    // 添加一个路过的点(添加一条直线的路径)
//    CGPathAddLineToPoint(path, NULL, 200, 100);
//    CGPathAddLineToPoint(path, NULL, 300, 0);
//    CGPathAddLineToPoint(path, NULL, 10, 200);
//    CGPathAddLineToPoint(path, NULL, 30, 0);
//    CGPathAddLineToPoint(path, NULL, 150, 40);
//    CGPathAddLineToPoint(path, NULL, 300, 0);
//    
//    
//    // 添加一条曲线路径
//    CGPathAddCurveToPoint(path, NULL, 10, 20, 100, 300, 150, 100);
//    CGPathAddCurveToPoint(path, NULL, 100, 150, 100, 0, 150, 100);
//    CGPathAddCurveToPoint(path, NULL, 120, 230, 105, 542, 10, 10);
//    
//    // 设置路径信息
//    [keyFrameAni setPath:path];
//    // 设置执行时间
//    [keyFrameAni setDuration:5.f];
//    
//    [button.layer addAnimation:keyFrameAni forKey:@"222"];
    
    
    
      // 过渡 变形
//    CATransition *transition = [CATransition animation];
//    
//    // 过渡动画CATransition 依靠type/subType改变动画效果
//    transition.duration = 2.f;
//    
//    // 动画类型
//    //[transition setType:kCATransitionMoveIn];
//    [transition setType:@"cameraIrisHollowClose"];
//    // 动画方向
//    [transition setSubtype:kCATransitionFromLeft];
//    
//    [button.layer addAnimation:transition forKey:@"333"];
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
LayeredForm : 支持窗体动画特效,透明,可以和LayeredControl实现任意透明效果等。。。包含LayeredWindowForm的功能 支持一部分带有Paint事件的普通控件,但是不能实现普通控件的背景透明效果! 控件类:Controls HotKey:支持全局热键绑定,事件驱动,可以开启和关闭 LayeredButton:按钮控件,支持按钮颜色设置,图片按钮,如果只设置一张正常状态下的按钮图片,则有鼠标移入加亮效果和鼠标按下变暗效果。边框设置,文字效果设置。 LayeredCheckButton:对LayeredButton的扩展,支持状态切换。 LayeredDragBar:支持对父容器的尺寸拖拽调整 LayeredFlashBox:支持透明Flash播放(当前版本不可用,请勿使用!) LayeredLabel:对文字的显示,文字效果设置 LayeredListBox:支自定义列表项目,支持横向和纵向滚动,支持平滑滚动。 LayeredPanel:在Layered模式下的容器控件 LayeredPictureBox:支持Gif 播放,支持多张图片合成动画播放。播放Gif时候不要频繁暂停和播放动画,容易导致线程阻塞。 LayeredTextBox:Layered模式下的文本编辑器。支持水印文字设置 LayeredTrackBar:进度条控件,支持图片进度条定义 动画类:Animations 通过设置LayeredForm的Animation.Effect属性来定义窗体动画特效。 包含了以下特效类:BlindWindowEffect、FadeinFadeoutEffect、GradualCurtainEffect、LevelScrollEffect、RandomCurtainEffect、RotateZoomEffect、ThreeDTurn、ZoomEffect 可以通过实现IEffects接口来实现自定义特效 DirectUI类:DirectUI 包含几个DirectUI控件。用于对以上控件的扩展和美化。部分LayeredControl包含DUIControl属性可以向其添加DirectUI控件。支持通过集合编辑器里面添加,只是不能在集合编辑器里面绑定事件,需要手动写代码绑定。通过集合编辑器添加的控件不一定能马上在设计器里看到效果,因为会有图像缓存,可能需要尝试调整控件大小等方式强制控件重绘,就可以看到效果了。 LayeredControl可以支持在普通窗体上使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值