我是靠谱客的博主 结实口红,这篇文章主要介绍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的全部内容,希望这篇文章对大家能有所帮助。

最后

以上就是结实口红最近收集整理的关于IOS实现自定义透明背景的tabbar的全部内容,更多相关IOS实现自定义透明背景内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(158)

评论列表共有 0 条评论

立即
投稿
返回
顶部