首先聲明完完全全是Github上的一個項目丛忆,覺得有用,便自己學(xué)著做了一遍仍秤。ASOAnimatedButton可以讓Button帶有動畫效果熄诡,是一個很好UIButton美化,開發(fā)的第三方資源诗力,以下是他的效果圖
項目首先是需要運cocoapods第三方資源庫凰浮,將ASOAnimatedButton導(dǎo)入項目中,具體步驟就不解釋了苇本。
接下來是項目的Storyboard視圖袜茧,主要是Tab bar View 組成,兩個部分:Expand,Rise瓣窄。
重要的代碼:
//設(shè)置YES,為了讓按鈕能夠兩種狀態(tài)轉(zhuǎn)換.
[self.menuButton initAnimationWithFadeEffectEnabled:YES];
menuButton是繼承了ASOAnimatedButton中ASOTwoStateButton.h的一個屬性笛厦。
//設(shè)置跳躍的距離,速度俺夕,和淡出效果的持續(xù)時間以及動畫的播放形式
[self.menuItemView setSpeed:[NSNumber numberWithFloat:0.3f]];
[self.menuItemView setBouncingDistance:[NSNumber numberWithFloat:0.3f]];
[self.menuItemView setAnimationStyle: ?ASOAnimationStyleRiseProgressively];
接下去就是按鈕被選中之后彈出4個按鈕的動作裳凸,
-(IBAction)menuButtonAction:(id)sender {
if ([sender isOn]){
//顯示“菜單項視圖”并展開“菜單項”按鈕
[self.menuButton addCustomView:self.menuItemView];
[self.menuItemView expandWithAnimationStyle:ASOAnimationStyleExpand];
}
else{
[self.menuItemView collapseWithAnimationStyle:ASOAnimationStyleExpand];
[self.menyButton removeCustomView:self.menuItemView interval:[self.menuItemView.collapsedViewDuration doubleValue];
}
}
這是本項目中重要的代碼,以上全是本人自己的觀點劝贸,復(fù)習(xí)用的姨谷,不喜歡的不要看。