大家好:我现在要实现一个动画效果:具体:点击image的区域,image左右摇摆。起初我自己以为是UIButton,上的前面图片,因为在上层图片左右摇摆的过程中,背景图片是不发生变化的。后来我看了UIButton的手册,在其自身的属性以及方法列中发现,根本没有动态变化的相关设置。现在真的很盲目,不知该朝着什么样的方向来完成。还请各位给点意见,不胜感激!

解决方案 »

  1.   

     UIImageView *backView=[[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; 
        self.view=[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; 
        [self.view addSubview:backView]; 
        backView.image=newImage; 
        backView.alpha=0.3; 
        
        CABasicAnimation *theAnimation1;    //定义动画 
        
        //左右摇摆 
        theAnimation1=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"]; 
        theAnimation1.fromValue=[NSNumber numberWithFloat:0]; 
        theAnimation1.toValue=[NSNumber numberWithFloat:-100]; 
        
        theAnimation1.duration=5.5;//动画持续时间 
        theAnimation1.repeatCount=6;//动画重复次数 
        theAnimation1.autoreverses=YES;//是否自动重复 
        
        [backView.layer addAnimation:theAnimation1 forKey:@"animateLayer"]; 
        
        [newImage release]; 
      

  2.   

    Thank you:Rey谢谢你的帮助,是我没有说清除。要是以图片的底边的中心点为一个轴心,这样摆动,英爱怎么实现呢。倘若事左右摇摆45。c,  望指点。谢谢
      

  3.   

    你弄几张差几帧的图片,弄一个UIImageView的动画就行了
      

  4.   

    UIView 旋转你要用到layer。