(swift版本)Tabbar點(diǎn)擊時(shí)候超炫小動(dòng)畫


對(duì)UITabBarController上TabBar按鈕動(dòng)畫詳細(xì)介紹swift版本-->>保證你有意外收獲,如有問(wèn)題歡迎指點(diǎn)。。OC版本TabBar按鈕動(dòng)畫


廢話就不多說(shuō)了直接上效果圖,這是我公司項(xiàng)目中加的動(dòng)畫,自己可以適當(dāng)?shù)募右孕薷姆Q自己想要的
#######效果


1.gif

點(diǎn)擊下面的按鈕時(shí)候是不是有動(dòng)畫 可能這個(gè)Gif動(dòng)畫有延遲 效果不明顯 下面上代碼。。
########代碼

class MainTabBar: UITabBarController {

var indexFlag = 0

override func viewDidLoad() {
super.viewDidLoad()
}

override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
if let index = tabBar.items?.index(of: item) {
if indexFlag != index {
animationWithIndex(index: index)
}
}
}

func animationWithIndex(index: Int) {
var arr = [UIView]()
for tabBarButton in tabBar.subviews {
if tabBarButton.isKind(of: NSClassFromString("UITabBarButton")!) {
arr.append(tabBarButton)
}
}
let pulse = CABasicAnimation(keyPath: "transform.scale")
pulse.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
pulse.duration = 0.08
pulse.repeatCount = 1
pulse.autoreverses = true
pulse.fromValue = NSNumber(value: 0.7)
pulse.toValue = NSNumber(value: 1.3)
arr[index].layer.add(pulse, forKey: nil)

indexFlag = index
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}

2016年09月29日 未完待續(xù)。。。如果有什么問(wèn)題可以+QQ1107385382詢問(wèn),如給你解決了問(wèn)題-->>請(qǐng)好評(píng)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容