首页 > 代码库 > 通过渲染改变tabBarItem的背景图片

通过渲染改变tabBarItem的背景图片

<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #703daa } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #3d1d81 } span.s1 { } span.s2 { color: #000000 } span.s3 { color: #3d1d81 } span.s4 { color: #4f8187 } span.s5 { color: #d12f1b } span.s6 { font: 18.0px "PingFang SC"; color: #d12f1b } span.s7 { color: #703daa }</style>

UITabBarController *tabVC = [[UITabBarController alloc] init];

    TestVC *vc = [TestVC new];

    tabVC.tabBar.tintColor = [UIColor greenColor];

    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];

    nav.tabBarItem.title = @"第一页";

    UIImage *img = [UIImage imageNamed:@"service_sel"];

    nav.tabBarItem.selectedImage = [img imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

    nav.tabBarItem.image = [img imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

通过渲染改变tabBarItem的背景图片