具有动画特效的UITabBar、可适配Lottie动画
pod 'TLAnimationTabBar', '~> 1.0.3'
TLAnimationTabBar
版本问题这可能是本地的CocoaPods仓库列表没有更新导致的。
运行以下命令更新本地的CocoaPods仓库列表:
pod repo update
然后通过以下命令查询
pod search TLAnimationTabBar
如果仍然查询不到最新版本,可以删除本地仓库重新安装
sudo rm -rf ~/.cocoapods/repos/master pod setup
TLAnimationTabBar.h
对外头文件
UITabBar+TLAnimation
监听TabBarItem的切换,并自带播放动画UITabBarItem+TLAnimation
给TabBarItem绑定一个动画属性TLTabBarAnimation
动画类的集合,所有动画都遵守TLAnimationProtocol
协议,为TabBarItem提供动画实例UITabBar和UITabBarItem的原生态
,保持完美兼容。不采用自定义组件,将动画独立化,以降低耦合度UITabBarButton
按钮属性,然后给其绑定一个动画(直接给这个按钮赋予动画效果)@interface UITabBarItem (TLAnimation)
/// 通过分类给TabBarItem绑定一个动画属性
@property(nonatomic, strong) id <TLAnimationProtocol>animation;
@end
TLAnimationProtocol协议
,根据协议定制动画,以保证调度统一。协议中将动画细化到UITabBarButton
或者其subView(imageView和Label) // 创建TabBarViewController的Child View Controller
ViewController *vc = [[ViewController alloc] init];
vc.view.backgroundColor = [UIColor whiteColor];
vc.tabBarItem = [[UITabBarItem alloc] initWithTitle:title image:[UIImage imageNamed:imgName] tag:tag];
// 创建动画
TLFumeAnimation *anm = [TLFumeAnimation new];
// 设置动画属性(重点)
vc.tabBarItem.animation = anm;