在很多情况下,我们也时常有这样的需求,就是在UITabBar切换的时候,添加一些动画效果

1.在UITabBar触发点击方法的时候捕获当前点击的item

2.使用coreAnimation设置动画效果

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {

    NSInteger index = [self.tabBar.items indexOfObject:item];

    if (self.indexFlag != index) {
[self animationWithIndex:index];
} }
// 动画
- (void)animationWithIndex:(NSInteger) index {
NSMutableArray * tabbarbuttonArray = [NSMutableArray array];
for (UIView *tabBarButton in self.tabBar.subviews) {
if ([tabBarButton isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
[tabbarbuttonArray addObject:tabBarButton];
}
}
CABasicAnimation*pulse = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
pulse.timingFunction= [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pulse.duration = 0.08;
pulse.repeatCount= ;
pulse.autoreverses= YES;
pulse.fromValue= [NSNumber numberWithFloat:0.7];
pulse.toValue= [NSNumber numberWithFloat:1.3];
[[tabbarbuttonArray[index] layer]
addAnimation:pulse forKey:nil]; self.indexFlag = index; }

最新文章

  1. channel Golang
  2. 解决python编码格式错误问题
  3. freemarker 数据做加减计算
  4. (分享)FreeVideo1.6.1 VIP视频播放器(支持下载)
  5. 一些IOS开发中的小技巧
  6. Software Engineering: 1. Introduction
  7. Android studio工具介绍
  8. CPU阿甘
  9. Jsp servlet 值传递。。
  10. 获取Spring的上下文环境ApplicationContext的方式
  11. 转:[译]Autoprefixer:一个以最好的方式处理浏览器前缀的后处理程序
  12. [解决]UserLibrary中的jar包不会自动发布Tomcat的lib目录下(基于MyEclipse2014)
  13. POJ2739 Sum of Consecutive Prime Numbers(尺取法)
  14. SPOJ GCDEX (数论)
  15. LFS,编译自己的Linux系统 - 前言
  16. [cocos2d-x][apk打包][Fatal signal 11][andriod]Eclipse编译Fatal signal 11报错-都是字符赋值惹的祸
  17. mac sourcetree启用外部合并工具(beyond compare)
  18. 小程序脚本语言WXS,你想要的都在这里了
  19. 设置DataGridView不自动创建生成列
  20. BZOJ 2242 [SDOI2011]计算器 | BSGS

热门文章

  1. centos 6.5下安装docker
  2. Java二维码登录流程实现(包含短地址生成,含部分代码)
  3. linux自己带的apache重新启动
  4. [GIF] GIF Loop Coder Single Mode
  5. 简化版可用于多线程的logger
  6. 贪心算法(2)-Kruskal最小生成树
  7. 新浪云(SAE)使用没有内置的django版本
  8. mysql索引详解,摘自《MySQL 5权威指南》
  9. 小白日记19:kali渗透测试之选择和修改EXP
  10. Android 高级UI设计笔记03:使用ListView实现左右滑动删除Item