广

IOS开发

  • IOS开发
  • android开发
  • PHP编程
  • JavaScript
  • ASP.NET
  • ASP编程
  • JSP编程
  • Java编程
  • 易语言
  • Ruby编程
  • Perl编程
  • AJAX
  • 正则表达式
  • C语言
  • 编程开发

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

    2018-04-08 09:03:58 次阅读 稿源:互联网
    广告

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

    ```//  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的全部内容,希望这篇文章对大家能有所帮助。

    一起学吧部分文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与一起学吧进行文章共享合作。

    广告
    广告
    广告