点击视图区域,实现图片image的动画效果:左右摇摆
大家好:我现在要实现一个动画效果:
具体:点击image的区域,image左右摇摆。
起初我自己以为是UIButton,上的前面图片,因为在上层图片左右摇摆的过程中,背景图片是不发生变化的。
后来我看了UIButton的手册,在其自身的属性以及方法列中发现,根本没有动态变化的相关设置。
现在真的很盲目,不知该朝着什么样的方向来完成。
还请各位给点意见,不胜感激! 图片 动画效果 左右摇摆 --------------------编程问答--------------------
--------------------编程问答-------------------- Thank you:Rey
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];
谢谢你的帮助,是我没有说清除。
要是以图片的底边的中心点为一个轴心,这样摆动,英爱怎么实现呢。
倘若事左右摇摆45。c, 望指点。谢谢 --------------------编程问答-------------------- 你弄几张差几帧的图片,弄一个UIImageView的动画就行了 --------------------编程问答-------------------- UIView 旋转
你要用到layer。 --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 除
补充:移动开发 , iPhone