1、设置透明Tabbar
self.tabBar.translucent = YES;
if (@available(iOS 13, *)) {
UITabBarAppearance *appearance = [self.tabBar.standardAppearance copy];
appearance.backgroundImage = [UIImage imageWithColor:[UIColor clearColor]];
appearance.shadowImage = [UIImage imageWithColor:[UIColor clearColor]];
[appearance configureWithTransparentBackground];
self.tabBar.standardAppearance = appearance;
} else {
self.tabBar.backgroundImage = [UIImage new];
self.tabBar.shadowImage = [UIImage new];
}
---基础设置
//设置背景颜色
self.tabBar.translucent = NO;
self.tabBar.barTintColor = [UIColor qqz_colorWithRGBHex:0x475769];
[[UITabBar appearance] setTintColor:YYTColorStr(@"")];//选中字体颜色
[[UITabBar appearance] setUnselectedItemTintColor:YYTColorStr(@"")];//未选中字体颜色
[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName:UIPingFangSCMediumFont(11)} forState:UIControlStateNormal];//设置字体大小
2、中间按钮放大效果
3、只放图片,并将图片位置向下调整
-(void)viewWillLayoutSubviews{
for (int i = 0; i<self.tabBar.items.count; i ++) {
UITabBarItem *itm = self.tabBar.items[i];
itm.imageInsets = UIEdgeInsetsMake(10, 0, -10, 0);
}
}
4、tabbar点击动效
点击后文字放大
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
//重新设置所有 item 的字体
for (UITabBarItem *unSelItem in tabBar.items) {
if (unSelItem == item) {//选中的设置他的状态
NSDictionary *textTitleOptions = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:12]};
[item setTitleTextAttributes:textTitleOptions forState:UIControlStateNormal];
}else {//未选中的设置他的状态
NSDictionary *textTitleOptions = @{NSFontAttributeName:[UIFont systemFontOfSize:10]};
[unSelItem setTitleTextAttributes:textTitleOptions forState:UIControlStateNormal];
}
}
}
点击后放大缩小等效果
给tabBarItem加点击效果动画 - 简书首先获取到tabBarItem,然后添加喜欢的动画,直接附代码https://www.jianshu.com/p/cc900e7b4ae2[先放大再缩小、Z轴旋转、向上移动、放大并保持]
tab点击,图片放大缩小动画_super_niuxinhuai的博客-CSDN博客项目中这次改版应产品要求加入tabbar点击做放大缩小动画,只改变图片,标题不做动画。先看效果图Demo地址图片做放大缩小动画,很好做。用CoreAnimation的帧动画就可以实现。不过貌似系统并没有开出开关于tabbar上的imageView这个属性。其实我们找到在tab上的imageView,这一切问题就好解决了。直接上代码声明一个tab继承系统tabbar#import https://blog.csdn.net/super_niuxinhuai/article/details/78761708UITabbarItem imageview 实现点击有放大然后还原的动画效果 - &清风& - 博客园在UITabBarController代理方法中添加动画,先通过KVC获取UIControl,然后在获取上面的UITabBarSwappableImageView,最后将动画添加到imageview的
https://www.cnblogs.com/weipeng168/p/10270409.html点击后图片弹动效果
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
for (UIControl *tabBarButton in self.tabBar.subviews) {
if ([tabBarButton isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
[tabBarButton addTarget:self action:@selector(tabBarButtonClick:) forControlEvents:UIControlEventTouchUpInside];
}
}
});
}
- (void)tabBarButtonClick:(UIControl *)tabBarButton
{
for (UIView *imageView in tabBarButton.subviews) {
if ([imageView isKindOfClass:NSClassFromString(@"UITabBarSwappableImageView")]) {
//需要实现的帧动画,这里根据需求自定义
CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];
animation.keyPath = @"transform.scale";
animation.values = @[@1.0,@1.3,@0.9,@1.15,@0.95,@1.05,@1.0];
animation.duration = 1;
animation.calculationMode = kCAAnimationCubic;
//把动画添加上去就OK了
[imageView.layer addAnimation:animation forKey:nil];
}
}
}
点击后产生动图效果
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
NSInteger beforeIndex = self.beforeSelected;
NSInteger currentIndex = [self getSelectedIndexWithTitle:item.title];
// 如果选中的是当前选中的,不做动画
if (beforeIndex == currentIndex) {
return;
}
// 选中交易不做动画
if (currentIndex == 2) {
return;
}
UIImageView *originImageView = item.qmui_imageView;
CGRect frame = originImageView.frame;
item.qmui_imageView.hidden = YES;
//所有的item,如果还在动画期间删除之前的动画,除了当前选中的item的,别的item的图片不隐藏
for (UITabBarItem *i in self.tabBar.items) {
if (![i.title isEqualToString:item.title]) {
i.qmui_imageView.hidden = NO;
}
for (id obj in i.qmui_barButton.subviews) {
if ([obj isKindOfClass:[LOTAnimationView class]]) {
LOTAnimationView *v = obj;
[v removeFromSuperview];
v.hidden = YES;
}
}
}
NSString *animationName = item.title;
if (![UUTokenLocalizable isChina]) {
if ([item.title isEqualToString:@"Wallet"]) {
animationName = @"钱包";
}else if ([item.title isEqualToString:@"Market"]) {
animationName = @"市场";
}else if ([item.title isEqualToString:@"Mine"]) {
animationName = @"我的";
}
}
if ([item.title isEqualToString:WCJ_LocalString(@"UUTOKEN_TRANSACTION")]) {
animationName = @"交易-暗黑";
}
LOTAnimationView *animationView = [LOTAnimationView animationNamed:animationName];
animationView.backgroundColor = [UIColor clearColor];
animationView.contentMode = UIViewContentModeScaleAspectFit;
animationView.frame = frame;
[item.qmui_barButton addSubview:animationView];
animationView.loopAnimation = NO;
animationView.animationProgress = 0;
[animationView play];
@weakify(animationView);
[animationView setCompletionBlock:^(BOOL animationFinished) {
@strongify(animationView);
animationView.hidden = YES;
[animationView removeFromSuperview];
item.qmui_imageView.hidden = NO;
}];
self.beforeSelected = currentIndex;
}
【参考uu】