生化危机6武器大师,mom,红楼梦 在线阅读
话不多说,直接看示例代码
``` // 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的全部内容,希望这篇文章对大家能有所帮助。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
网友评论