ios动画
来源:互联网 发布:安卓6.0 移动数据开关 编辑:程序博客网 时间:2024/03/28 21:35
ios4.0以前使用的设置动画的方法,平时不建议用,偶尔有需要的话可以用
// 开始动画
[UIView beginAnimations:@"fdsf" context:nil];
// 设置动画持续时间
[UIViewsetAnimationDuration:3];
// 设置动画持续时间和动画内容
[UIViewanimateWithDuration:2animations:^{
self.green.center =CGPointMake(100,100);
}];
// 设置动画持续时间和动画内容以及动画完成后做什么事
[UIView animateWithDuration:3 animations:^{
self.green.center =CGPointMake(100,100);
}completion:^(BOOL finished) {
NSLog(@"fdsf");
}];
// 设置动画持续时间 推迟几秒开始 选择权 动画内容 动画结束后做什么事
[UIViewanimateWithDuration:3delay:2options:UIViewAnimationOptionRepeat animations:^{
// 动画重复次数
[UIViewsetAnimationRepeatCount:2];
self.green.center =CGPointMake(100,100);
}completion:^(BOOL finished) {
NSLog(@"fds");
}];
// 结束动画
[UIViewcommitAnimations];
以下是经常使用的三种种动画:CA动画. (CA是效果不会改变属性值)
// 属性动画
CABasicAnimation *animation = [CABasicAnimationanimationWithKeyPath:@"bounds"];
animation.fromValue = [NSValuevalueWithCGRect:CGRectMake(0,0, 0, 0)];
animation.toValue = [NSValuevalueWithCGRect:CGRectMake(0,0, 300, 200)];
animation.duration = 3;
[self.view.layeraddAnimation:animation forKey:@"hello"];
CAKeyframeAnimation *keyFrameAnimation = [CAKeyframeAnimationanimationWithKeyPath:@"position"];
CGFloat centerx = self.green.center.x;
CGFloat centery = self.green.center.y;
keyFrameAnimation.values = [NSArrayarrayWithObjects:[NSValuevalueWithCGPoint:CGPointMake(centerx, centery)],[NSValuevalueWithCGPoint:CGPointMake(centerx-10, centery)],[NSValuevalueWithCGPoint:CGPointMake(centerx, centery)],[NSValuevalueWithCGPoint:CGPointMake(centerx+10, centery)],[NSValuevalueWithCGPoint:CGPointMake(centerx, centery)],[NSValuevalueWithCGPoint:CGPointMake(centerx-10, centery)],[NSValuevalueWithCGPoint:CGPointMake(centerx, centery)],nil];
[self.green.layeraddAnimation:keyFrameAnimation forKey:@"fds"];
// 过渡动画 (一般设置一个容器在这个容器内做页面的跳转)
CATransition *transition = [CATransition animation];
transition.type =@"cube";
transition.subtype =kCATransitionFromRight;
transition.duration =3;
transition.startProgress =0;
transition.endProgress =0.8;
[self.red.layeraddAnimation:transition forKey:@"fds"];
- iOS动画 核心动画
- iOS动画 UIView动画
- iOS动画 CATransition动画
- iOS 动画 UIView动画
- iOS动画-基础动画
- ios 动画
- IOS动画
- Ios 动画
- ios动画
- IOS 动画
- iOS动画
- ios动画
- ios动画
- iOS动画
- iOS 动画
- ios 动画
- iOS 动画
- iOS 动画
- openCV中IplImage的使用
- java正则表达式提取数字的方法实例
- 用的友盟安卓社会化组件,然后客户端安装了微博4.2,做的应用用友盟的新浪授权登陆 提示:sso package or sign error。
- MD5及邮件发送
- linux shell
- ios动画
- 职场新人如何招架同事倚老卖老?
- 地址空间的归纳总结
- 读书笔记
- Python实现递归解析json
- c++ stl algorithm: std::find, std::find_if
- nginx+keepalived负载均衡可用框架(一 keepalived双机系统)
- [Linux] 文件系统和df,du命令
- Spark实现的hello world<转>