打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
CAKeyframeAnimation例子
    -(CAAnimation*)animation {
    
    
   CAKeyframeAnimation* animation;
    animation =[CAKeyframeAnimation animation];
   animation.path = path;
   CGPathRelease(path);
   animation.duration = 5;
   animation.repeatCount = 10000;
    animation.calculationMode = @"cubic";
   animation.calculationMode=kCAAnimationCubicPaced;
      return animation;
}

-(CAAnimation*)fadeInOutAnimation{
   CABasicAnimation* animation = [CABasicAnimationanimationWithKeyPath:@"opacity"];
   animation.duration = 5;
   animation.repeatCount =10000;
   animation.toValue = [NSNumbernumberWithFloat:.4];
   animation.autoreverses = YES;
    returnanimation;
}

-(void)startMoving{
    
    
   // [self.layeraddAnimation:[self animation] forKey:@"position"];//圆周运动
   [imgView.layer addAnimation:[self animation]forKey:@"position"];
    [self.layeraddAnimation:[self fadeInOutAnimation]forKey:@"opacity"];//阴影转动效果
    
   
   self.layer.needsDisplayOnBoundsChange =YES;
    [UIViewsetAnimationCurve:UIViewAnimationCurveLinear];
   self.layer.position = CGPointMake(100,100);
   self.layer.opacity = .4;
}

- (void) dealloc
{
   CGPathRelease(path);

    [superdealloc];
}


-(void)initPath{
    
    
    path =CGPathCreateMutable();

    CAShapeLayer*line =  [CAShapeLayer layer];
    
    
   line.lineWidth = 2.0f ;
   line.strokeColor = [UIColor orangeColor].CGColor;
   line.fillColor = [UIColor clearColor].CGColor;
    
   CGPathAddEllipseInRect(path, NULL,CGRectMake(100, 200, 200, 100));//椭圆路径,关键步骤。

    line.path =path;
   CGPathRelease(path);
    [self.layeraddSublayer:line];
}

- (id)initWithFrame:(CGRect)aRect{
    self =[super initWithFrame:aRect];
    if(self !=nil){
      [self initPath];

      imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 165, 82)];
      imgView.image = [UIImageimageNamed:@"weather_sun.png.png"];
      imgView.opaque = NO;
       [self addSubview:imgView];
      [self startMoving];
      [imgView release];
      
    }
    returnself;
}

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
iOS核心动画高级技巧-4
Core Animation一些Demo总结 (动态切换图片、大转盘、图片折叠、进度条等动画效果)
iOS
IOS 核心动画之CAKeyframeAnimation
iPhone/iOS Core Animation开发总结(CALayer)
iOS 实现渐变背景动画效果的Switch
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服