免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1413 | 回复: 1
打印 上一主题 下一主题

窗口动画 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-12 21:23 |只看该作者 |倒序浏览
窗口动画









首先,导入QuartzCore.framework,然后在头文件中加入:#import <QuartzCore/QuartzCore.h>





Ios代码
  1. 1.- (void)viewDidLoad {  
  2. 2.    [super viewDidLoad];  
  3. 3.      
  4. 4.    CGRect rect = CGRectMake(0.0f, 0.0f, 320.0f, 200.0f);  
  5. 5.    UIView *myView = [[UIView alloc] initWithFrame:rect];  
  6. 6.    myView.backgroundColor = [UIColor redColor];  
  7. 7.      
  8. 8.    CABasicAnimation *animation1;      
  9. 9.    animation1 = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];  
  10. 10.    animation1.duration = 5;  
  11. 11.    animation1.repeatCount = 3;  
  12. 12.    animation1.autoreverses = YES;  
  13. 13.    animation1.fromValue = [NSNumber numberWithFloat:0];  
  14. 14.    animation1.toValue = [NSNumber numberWithFloat:-100];  
  15. 15.    [myView.layer addAnimation:animation1 forKey:@"animateLayer"];  
  16. 16.      
  17. 17.    [self.view addSubview:myView];  
  18. 18.      
  19. 19.    CABasicAnimation *animation2;      
  20. 20.    animation2 = [CABasicAnimation animationWithKeyPath:@"transform.translation.y"];  
  21. 21.    animation2.duration = 1;  
  22. 22.    animation2.repeatCount = 10;  
  23. 23.    animation2.autoreverses = YES;  
  24. 24.    animation2.fromValue = [NSNumber numberWithFloat:0];  
  25. 25.    animation2.toValue = [NSNumber numberWithFloat:-60];  
  26. 26.    [self.view.layer addAnimation:animation2 forKey:@"animateLayer"];  
  27. 27.    [myView release];  
  28. 28.}  
复制代码

论坛徽章:
0
2 [报告]
发表于 2011-12-23 22:01 |只看该作者
谢谢分享  希望于楼主多多交流
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP