博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
第三十八篇、给UITabBar按钮的动画效果
阅读量:4519 次
发布时间:2019-06-08

本文共 1156 字,大约阅读时间需要 3 分钟。

 在很多情况下,我们也时常有这样的需求,就是在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= 1;    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;}

 

转载于:https://www.cnblogs.com/HJQ2016/p/5918027.html

你可能感兴趣的文章
golang写入csv
查看>>
基础2
查看>>
java基础篇---网络编程(UDP程序设计)
查看>>
Kafka Producer相关代码分析【转】
查看>>
LeetCode 121. Best Time to Buy and Sell Stock
查看>>
麻省理工学院公开课-第四讲:快速排序 及 随机化 算法
查看>>
pycharm 的包路径设置export PYTHONPATH=$PYTHONPATH
查看>>
SQL语句创建函数
查看>>
解决mysql无法显示中文/MySQL中文乱码问号等问题
查看>>
CentOS 7.2 配置mysql5.7
查看>>
python输出转义字符
查看>>
java基础43 IO流技术(输入字节流/缓冲输入字节流)
查看>>
计算一个整数二进制中1的个数
查看>>
netdom join 错误:指定的域不存在,或无法联系。
查看>>
Android中Dialog的使用
查看>>
Android Activity接收Service发送的广播
查看>>
[Leetcode] Spiral Matrix | 把一个2D matrix用螺旋方式打印
查看>>
加速和监控国际网络
查看>>
【Flex】读取本地XML,然后XML数据转成JSON数据
查看>>
字符串循环右移-c语言
查看>>