当前位置: 首页 > news >正文

给自定义tabBar的按钮添加点击放大缩小的动画

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

// 一句话,写在UITabBarController.m脚本中,tabBar是自动执行的方法  
  
  
// 点击tabbarItem自动调用  
-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item  
{  
    NSInteger index = [self.tabBar.items indexOfObject:item];  
  
    [self animationWithIndex:index];  
  
    if([item.title isEqualToString:@"发现"])  
    {  
      // 也可以判断标题,然后做自己想做的事<img alt="得意" src="http://static.blog.csdn.net/xheditor/xheditor_emot/default/proud.gif" />  
    }  
  
}  
- (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= 1;  
    pulse.autoreverses= YES;  
    pulse.fromValue= [NSNumber numberWithFloat:0.7];  
    pulse.toValue= [NSNumber numberWithFloat:1.3];  
    [[tabbarbuttonArray[index] layer]  
     addAnimation:pulse forKey:nil];  
   
}

转载于:https://my.oschina.net/wenchengxu123/blog/863927

相关文章:

  • idea 实现热部署
  • Advanced Auto Layout:Working with Self-Sizing Table View Cells
  • 震精 - PostgreSQL 单机3.9 万亿/天(计数器、序列、自增)
  • 什么是 SHTML
  • mysql57修改root密码
  • python3编码问题终结者--还搞不懂你来找我
  • Python(三)之Python的表达式和语句概述
  • # 20155222 2016-2017-2 《Java程序设计》第5周学习总结
  • 消息中间件简介
  • 画像分析(4-1)智能搬迁和数据订阅
  • Bzoj4771 七彩树
  • Oracle 数据库备份脚本
  • C8051F340 USB Fn hacking
  • Android Studio 开始运行错误
  • 对象——浅识
  • [LeetCode] Wiggle Sort
  • 【JavaScript】通过闭包创建具有私有属性的实例对象
  • 2017 年终总结 —— 在路上
  • NSTimer学习笔记
  • SAP云平台运行环境Cloud Foundry和Neo的区别
  • TCP拥塞控制
  • Webpack4 学习笔记 - 01:webpack的安装和简单配置
  • 分类模型——Logistics Regression
  • 海量大数据大屏分析展示一步到位:DataWorks数据服务+MaxCompute Lightning对接DataV最佳实践...
  • 开源中国专访:Chameleon原理首发,其它跨多端统一框架都是假的?
  • 前端路由实现-history
  • 设计模式走一遍---观察者模式
  • 使用parted解决大于2T的磁盘分区
  • 算法-插入排序
  • mysql 慢查询分析工具:pt-query-digest 在mac 上的安装使用 ...
  • 交换综合实验一
  • #Linux(帮助手册)
  • #pragma once
  • $ git push -u origin master 推送到远程库出错
  • (2.2w字)前端单元测试之Jest详解篇
  • (TipsTricks)用客户端模板精简JavaScript代码
  • (二) Windows 下 Sublime Text 3 安装离线插件 Anaconda
  • (翻译)Quartz官方教程——第一课:Quartz入门
  • (附程序)AD采集中的10种经典软件滤波程序优缺点分析
  • (原创)Stanford Machine Learning (by Andrew NG) --- (week 9) Anomaly DetectionRecommender Systems...
  • (转载)(官方)UE4--图像编程----着色器开发
  • .class文件转换.java_从一个class文件深入理解Java字节码结构
  • .NET Core Web APi类库如何内嵌运行?
  • .net core 控制台应用程序读取配置文件app.config
  • .net 程序发生了一个不可捕获的异常
  • .net中我喜欢的两种验证码
  • @converter 只能用mysql吗_python-MySQLConverter对象没有mysql-connector属性’...
  • @LoadBalanced 和 @RefreshScope 同时使用,负载均衡失效分析
  • [AIGC 大数据基础]hive浅谈
  • [AutoSAR 存储] 汽车智能座舱的存储需求
  • [C#]C# winform实现imagecaption图像生成描述图文描述生成
  • [CQOI 2011]动态逆序对
  • [ES-5.6.12] x-pack ssl
  • [Flex][问题笔记]TextArea滚动条问题
  • [hihocoder1395] 最大权闭合子图