iOS UITabbar去掉顶部的线添加背景图片

CGRect rect = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);

UIGraphicsBeginImageContext(rect.size);

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);

CGContextFillRect(context, rect);

UIImage *img = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

[self.tabBar setBackgroundImage:img];

[self.tabBar setShadowImage:img];

[self.tabBar setBackgroundImage:[UIImage imageNamed:@"你的图片"]];

代码直接可用更换你的图片就好了,有用到的点个like 谢谢~~~!!

你可能感兴趣的:(iOS UITabbar去掉顶部的线添加背景图片)