iOS中給自定義tabBar的按鈕添加點擊放大縮小的動畫效果
更新時間:2016年11月23日 14:20:49 投稿:mrr
這篇文章主要介紹了iOS中給自定義tabBar的按鈕添加點擊放大縮小的動畫效果的相關資料,非常不錯,具有參考解決價值,需要的朋友可以參考下
之前想過一些通過第三方的方式實現(xiàn)動畫,感覺有點麻煩,就自己寫了一個
不足之處還望大家多多指出
// 一句話,寫在UITabBarController.m腳本中,tabBar是自動執(zhí)行的方法 // 點擊tabbarItem自動調(diào)用 -(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item { NSInteger index = [self.tabBar.items indexOfObject:item]; [self animationWithIndex:index]; if([item.title isEqualToString:@"發(fā)現(xiàn)"]) { // 也可以判斷標題,然后做自己想做的事<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]; }
以上所述是小編給大家介紹的iOS中給自定義tabBar的按鈕添加點擊放大縮小的動畫效果,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關文章
iOS中解決Xcode9的Log日志無法輸出中文的問題小結(jié)
這篇文章主要介紹了iOS中解決Xcode9的Log日志無法輸出中文的問題小結(jié),需要的朋友可以參考下2017-11-11iOS?UITextView?實現(xiàn)類似微博的話題、提及用戶效果
這篇文章主要介紹了iOS?UITextView?實現(xiàn)類似微博的話題、提及功能,基本思路是使用正則匹配出成對的#,再利用UITextView的富文本實現(xiàn)高亮效果,需要的朋友可以參考下2022-06-06