少见的几种动画效果
来源:互联网 发布:vue2.0源码分析 编辑:程序博客网 时间:2024/06/08 06:26
转摘 http://marshal.easymorse.com/archives/3727,自己调试通过的代码
包含
#import <QuartzCore/QuartzCore.h>
- (void)loadView
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation: UIStatusBarAnimationSlide];
UIImage *image=[UIImage imageNamed:@"back0.jpg"];
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, 768, 1024, 8, 4 * 768, colorSpace, kCGImageAlphaPremultipliedFirst);
CGRect rect = CGRectMake(0, 0, 768, 1024);
CGColorRef fillColor = [[UIColor whiteColor] CGColor];
CGContextSetFillColor(context, CGColorGetComponents(fillColor));
CGContextMoveToPoint(context, 160.0f, 230.0f);
CGContextAddLineToPoint(context, 600.0f, 230.0f);
CGContextAddLineToPoint(context, 600.0f, 100.0f);
CGContextAddLineToPoint(context, 370.0f, 50.0f);
CGContextAddLineToPoint(context, 200.0f, 100.0f);
CGContextClosePath(context);
CGContextClip(context);
CGContextDrawImage(context, rect, image.CGImage);
CGImageRef imageMasked = CGBitmapContextCreateImage(context);
CGContextRelease(context);
UIImage *newImage = [UIImage imageWithCGImage:imageMasked];
CGImageRelease(imageMasked);
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;//是否自动重复*/
//旋转
//theAnimation1=[CABasicAnimation animationWithKeyPath:@"transform"];
//theAnimation1.toValue = [ NSValue valueWithCATransform3D: CATransform3DMakeRotation(3.1415, 0, 0, 1.0) ];
//缩放
theAnimation1=[CABasicAnimation animationWithKeyPath:@"transform.scale"];
theAnimation1.toValue = [NSNumber numberWithDouble:2.5];
[backView.layer addAnimation:theAnimation1 forKey:@"animateLayer"];
[newImage release];
[image release];
}
//按钮从大变小,然后小于正常显示的值,最后恢复正常(就是缩小并有回弹的效果)
UIButton *button = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(20,100, 200, 30);
[button setBackgroundColor:[UIColorredColor]];
[button setTitle:@"FirstViewController"forState:UIControlStateNormal];
[button addTarget:selfaction:@selector(buttonAction:)forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
CABasicAnimation * animation = [CABasicAnimationanimationWithKeyPath:@"transform.scale"];
[animation setFromValue:[NSNumbernumberWithFloat:8]];
[animation setToValue:[NSNumbernumberWithFloat:1]];
[animation setDuration:5];
[animation setTimingFunction:[CAMediaTimingFunctionfunctionWithControlPoints:.4 :1.3 :1 :1]];
[button.layer addAnimation:animationforKey:@"bounceAnimation"];
[button release];
- 少见的几种动画效果
- 几种的实现动画效果1
- 几种的实现动画效果2
- ViewPager的几种动画效果源代码
- animation 几种动画效果
- CoolUIViewAnimations 几种动画效果
- shell中的几种少见的变量继承(传递)方式
- 几种常用的Interpolator(插值器)的动画效果
- iOS开发常用的几种动画效果
- iOS开发-autolayout动画效果实现的几种方法
- Activity切换的几种动画效果设置
- 转一个几种常用排序算法的动画效果
- CATransition完成几种动画效果
- CATransition完成几种动画效果
- IOS UITableViewCell常用几种动画效果
- 少见的国产动画片
- 极少见的跑车
- bash少见的用法
- 用户、角色、权限
- 日本語 window.close()メッセージを表示しないように
- 分别使用FlyJSONP和JQuery实现跨域的异步请求
- IMPLEMENT_DYNCREATE与DECLARE_DYNCREATE
- C++编程技能考题
- 少见的几种动画效果
- kettle 的命令调用
- WinCE下Touch Panel驱动介绍
- 兼容 IE6、IE7、FF 的“加入收藏”
- 如何配置JVM的GC参数
- 如何编写优质的API文档
- 配置svn的问题,
- Java反射机制
- 定位EXC_BAD_ACCESS错误 设置NSZombieEnabled