TabBarItem切換動畫

2021-07-25 11:42:24 字數 1082 閱讀 2336

為工程的底部工具欄新增乙個簡單而小萌的動畫,原理是在

uitabbarcontroller

的裡面切換item時的方法中新增乙個縮放動畫。

實現的效果如下gif圖,

**如下,

//tabbar選中item

- (void

)tabbar:(

uitabbar

*)tabbar didselectitem:(

uitabbaritem

*)item

#pragma mark - tabbar item

選中時的動畫

- (void

)animationwithindex:(

nsinteger

) index

}cabasicanimation

* animation = [

cabasicanimation

animationwithkeypath

:@"transform.scale"

];animation.

timingfunction

= [camediatimingfunction

functionwithname

:kcamediatimingfunctioneaseineaseout

];animation.

duration

=0.1

;animation.

repeatcount=1

;animation.

autoreverses

=yes

;animation.

fromvalue

[email protected]

;animation.

tovalue

[email protected]

;[[tabbarbuttonarray[index]

layer

]addanimation

:animation

forkey

:nil];}

activities切換動畫

package gogler.myandroid public class activityintentactivity extends activity intent.setclass activityintentactivity.this,secondactivity.class activit...

Acvivity切換動畫

public class animation extends activity private onclicklistener mfadelistener new onclicklistener private onclicklistener mzoomlistener new onclicklis...

ViewPager切換動畫

01.簡單呼叫google官方文件 depthpagetransformer類和 zoomoutpagetransformer類來實現viewpager的切換動畫 02.觀察api的規律,自定義自己的切換動畫 例子 rotatepagetransformer 03.自定義viewpager實現動畫切...