IOS----Core Animation介绍4
来源:互联网 发布:数据库脱机 编辑:程序博客网 时间:2024/05/19 19:15
原文地址:http://superman474.blog.163.com/blog/static/120661462011857653190/
animation(动画)
1.animation类和timing(时序)
2.implicit animation
下面一句话就是简单的触发一个隐含的动画时layer从当前的position到新的position。
// assume that the layer is current positioned at (100.0,100.0)
theLayer.position=CGPointMake(500.0,500.0);
也可以一次改变多个layer属性,或者同时改变多个layer的属性值都可以。下面代码说明了此。
// animate theLayer's opacity to 0 while moving it
// further away in the layer
theLayer.opacity=0.0;
theLayer.zPosition=-100;
// animate anotherLayer's opacity to 1
// while moving it closer in the layer
anotherLayer.opacity=1.0;
anotherLayer.zPosition=100.0;
3.明确的动画
明确的动画需要我们去创建一个animation对象,设置开始和结束值。一个明确的动画不会自动开始除非你将其应用到layer中。下面的代码将创建一个明确的动画,在3秒中过度一个layer的opacity从opaque到full transparent(全部透明),并且在返回原样。直到将其加到layer上时,动画才开始。
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"];
theAnimation.duration=3.0;
theAnimation.repeatCount=2;
theAnimation.autoreverses=YES;
theAnimation.fromValue=[NSNumber numberWithFloat:1.0];
theAnimation.toValue=[NSNumber numberWithFloat:0.0];
[theLayer addAnimation:theAnimation forKey:@"animateOpacity"];
// The selection layer will pulse continuously.
// This is accomplished by setting a bloom filter on the layer
// create the filter and set its default values
CIFilter *filter = [CIFilter filterWithName:@"CIBloom"];
[filter setDefaults];
[filter setValue:[NSNumber numberWithFloat:5.0] forKey:@"inputRadius"];
// name the filter so we can use the keypath to animate the inputIntensity
// attribute of the filter
[filter setName:@"pulseFilter"];
// set the filter to the selection layer's filters
[selectionLayer setFilters:[NSArray arrayWithObject:filter]];
// create the animation that will handle the pulsing.
CABasicAnimation* pulseAnimation = [CABasicAnimation animation];
// the attribute we want to animate is the inputIntensity
// of the pulseFilter
pulseAnimation.keyPath = @"filters.pulseFilter.inputIntensity";
// we want it to animate from the value 0 to 1
pulseAnimation.fromValue = [NSNumber numberWithFloat: 0.0];
pulseAnimation.toValue = [NSNumber numberWithFloat: 1.5];
// over a one second duration, and run an infinite
// number of times
pulseAnimation.duration = 1.0;
pulseAnimation.repeatCount = HUGE_VALF;
// we want it to fade on, and fade off, so it needs to
// automatically autoreverse.. this causes the intensity
// input to go from 0 to 1 to 0
pulseAnimation.autoreverses = YES;
// use a timing curve of easy in, easy out..
pulseAnimation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut];
// add the animation to the selection layer. This causes
// it to begin animating. We'll use pulseAnimation as the
// animation key name
[selectionLayer addAnimation:pulseAnimation forKey:@"pulseAnimation"];
(上面的代码用到了过滤器)
4.启动和停止显式动画
- IOS----Core Animation介绍4
- IOS----Core Animation介绍4
- IOS----Core Animation介绍1
- IOS----Core Animation介绍2
- IOS----Core Animation介绍3
- IOS----Core Animation介绍5
- IOS----Core Animation介绍2
- IOS----Core Animation介绍3
- IOS----Core Animation介绍1
- IOS----Core Animation介绍2
- IOS----Core Animation介绍3
- IOS----Core Animation介绍5
- iOS开发有关Core Animation的介绍
- Core Animation介绍1
- Core Animation基础介绍
- Core Animation基础介绍
- iOS-Core-Animation-Advanced-Techniques(七-4)
- IOS开发—Core Animation核心动画介绍
- The reference to entity "" must end with the ';' delimiter
- execute immediate
- 使用afconvert转换WAV文件
- Solaris 下安装jdk6的步骤
- IOS----Core Animation介绍3
- IOS----Core Animation介绍4
- 50个必备的实用jQuery代码段
- java IO (六) 扩展应用
- 基于STM32 8通道ADC采样实现源代码(转) 以后设计参考使用
- IOS----Core Animation介绍5
- 浮点数问题
- android service 学习(下)
- vc小知识
- 如何将 Oracle 数据导出到 Excel表中 --转载