iOS --用CABasicAnimation实现简单的动画效果
2014-06-26 14:59
501 查看
直接上代码了,大家可以根据我的代码进行创新,达到自己想要的动画效果!
UIImage *image=[UIImage
imageNamed:@"游戏背景.jpg"];
UIImageView *backView=[[UIImageView
alloc] initWithFrame:CGRectMake(100,
100, 200,
250)];
self.view=[[UIView
alloc] initWithFrame:[[UIScreen
mainScreen] applicationFrame]];
[self.view
addSubview:backView];
backView.image=image;
backView.alpha=1.0;
//定义动画
CABasicAnimation *theAnimation1;
// //左右摇摆
// theAnimation1=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
// theAnimation1.fromValue=[NSNumber numberWithFloat:0];
// theAnimation1.toValue=[NSNumber numberWithFloat:-100];
//
//旋转
// theAnimation1=[CABasicAnimation animationWithKeyPath:@"transform"];
// theAnimation1.toValue = [ NSValue valueWithCATransform3D: CATransform3DMakeRotation(3.1415, 0, 0, 1.0) ];
//缩放
theAnimation1=[CABasicAnimation
animationWithKeyPath:@"transform.scale"];
theAnimation1.toValue = [NSNumber
numberWithDouble:1.5];
theAnimation1.duration=1.0;//动画持续时间
theAnimation1.repeatCount=6;//动画重复次数
theAnimation1.autoreverses=YES;//是否自动重复
[backView.layer
addAnimation:theAnimation1
forKey:@"animateLayer"];
相关文章推荐
- iOS-实现简单的动画效果
- iOS-实现简单的动画效果
- ios开发之简单实现loading动画效果
- iOS简单的动画效果实现
- ios开发之简单实现loading动画效果
- 关于iOS 简单动画效果的实现(用 beginAnimations 和 commitAnimations 来实现最简单的动画)
- iOS 简单动画效果实现的三种方式
- ios气泡动画效果的简单实现
- IOS开发-CGAffineTransform的用法,实现一些简单动画效果
- ios开发之简单实现loading动画效果
- iphone--使用NSTimer与iphone的简单动画,实现飘雪效果
- 使用NSTimer与iphone的简单动画,实现飘雪效果
- iOS实现简单图文混排效果
- iOS动画效果和实现
- iOS 简单动画效果
- IOS开发之UIView动画效果的实现
- Java之简单的图片动态显示(实现类似GIF动画效果)
- IOS中通过Core Animation实现简单动画
- 使用NSTimer与iphone的简单动画,实现飘雪效果
- iOS动画效果和实现