//写在TabBarController .m文件中
- (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*action = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
action.timingFunction= [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
action.duration = 0.08;
action.repeatCount= 1;
action.autoreverses= YES;
action.fromValue= [NSNumber numberWithFloat:0.7];
action.toValue= [NSNumber numberWithFloat:1.2];
[[tabbarbuttonArray[index] layer]
addAnimation:action forKey:nil];
self.indexFlag = index;
}
tabbarItem动画
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 使用最经典的一张图来介绍一下动画抽象类CAAnimation.同NSOperation一样,都是抽象类,并不具备封...
- A-关键帧动画 关键帧动画就是在动画控制过程中开发者指定主要的动画状态,各个状态间动画如何进行则由系统自动运算补充...
- 项目需求: 双击TabBarItem刷新页面,并且TabBar添加旋转Loading动画,如图: 动画原理:给La...
- 介绍 iOS中SpringAnimation是一种常见的动画,其效果就像弹簧一样,会在end point周围摆动几...