IOS自定义透明背景tabbar IOS实现自定义透明背景的tabbar

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

IOS自定义透明背景tabbar IOS实现自定义透明背景的tabbar

  2021-03-22 我要评论
想了解IOS实现自定义透明背景的tabbar的相关内容吗,在本文为您仔细讲解IOS自定义透明背景tabbar的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:ios,tabbar,透明,ios,tabbar,设置透明,ios,tabbar背景透明度,下面大家一起来学习吧。

话不多说,直接看示例代码

```
//  UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, tabBarHeight + 5)];
//  [imageView setImage:[self createImageWithColor:[UIColor clearColor]]];
//  [imageView setContentMode:UIViewContentModeScaleToFill];
//  [self.tabBar insertSubview:imageView atIndex:0];

  //覆盖原生Tabbar的上横线
//  [[UITabBar appearance] setShadowImage:[self createImageWithColor:[UIColor clearColor]]];
//背景图片为透明色
//  [[UITabBar appearance] setBackgroundImage:[self createImageWithColor:[UIColor clearColor]]];
  self.tabBar.backgroundColor = [UIColor clearColor];
//设置为半透明
  self.tabBarController.tabBar.translucent = YES;

```
```
-(UIImage*) createImageWithColor:(UIColor*) color
{
  CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
  UIGraphicsBeginImageContext(rect.size);
  CGContextRef context = UIGraphicsGetCurrentContext();
  CGContextSetFillColorWithColor(context, [color CGColor]);
  CGContextFillRect(context, rect);
  UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  return theImage;
}


```

以上就是在IOS实现自定义透明背景的tabbar的全部内容,希望这篇文章对大家能有所帮助。

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们