Tabbar頁面切換彈性動畫

寫在自己封裝的TabBarViewController里即可


@interface WTTabBarViewController ()
@property (assign,nonatomic) NSInteger index;
@end

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
    NSInteger selectIndex = [tabBar.items indexOfObject:item];
    if (selectIndex != _index)  // 是否重復(fù)點擊 (需要重復(fù)點擊直接注釋)
        [self animationWithIndex:selectIndex];
}

- (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.2;   //time
    pulse.repeatCount = 1;  //重復(fù)次數(shù)
    pulse.autoreverses = YES;   //回到初始狀態(tài)
    pulse.fromValue = [NSNumber numberWithFloat:0.7];   //初始伸縮倍數(shù)
    pulse.toValue = [NSNumber numberWithFloat:1.3];     //結(jié)束伸縮倍數(shù)
    [[tabbarbuttonArray[index] layer] addAnimation:pulse forKey:nil];
    
    _index = index;
    
}


gif5新文件-2.gif

借鑒http://www.cnblogs.com/yajunLi/p/6288811.html 感謝分享

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 178,733評論 25 709
  • 前些日子從@張鑫旭微博處得一份推薦(Front-end-tutorial),號稱最全的資源教程-前端涉及的所有知識...
    谷子多閱讀 4,477評論 0 44
  • 我不是在說我自己-寫在前面~ 要有多堅強,才敢念念不忘 你可曾知道,我總在下雨時分 寧靜與憂傷之間,最想念你 你可...
    欲為小漢閱讀 281評論 0 0
  • 失業(yè)加失戀, 再加本身就是很宅的人 呵呵有得熬了 想得夠多 多的是時間想 呵呵 等著崩潰吧 呵呵呵呵
    阿渴閱讀 354評論 0 1
  • 小巖#每天500字#D6 去年在各種社群風(fēng)行的時候知道了熊貓書院,覺得這個10個月的閱讀活動太好了,就報名參加了,...
    巖巖Fighting閱讀 271評論 0 0

友情鏈接更多精彩內(nèi)容