UITabBarController *tabVC = [[UITabBarController alloc] init];
UIImage *whiteImage = [self imageWithColor:[UIColor whiteColor]];
if (@available(iOS 13.0, *)) {
// 手动放一张白色底图遮住系统tabbar的顶部线条
// blankView颜色必须设置
UIView *blankView = [[UIView alloc] initWithFrame:CGRectMake(0, -0.5, UIScreen.mainScreen.bounds.size.width, 0.5)];
blankView.backgroundColor = UIColor.whiteColor;
[tabVC.tabBar addSubview:blankView];
} else {
[tabVC.tabBar setBackgroundImage:whiteImage];
[tabVC.tabBar setShadowImage:whiteImage];
}
// 通过颜色生成图片
- (UIImage *)imageWithColor:(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 *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
iOS13 UITabbar 隐藏顶部分割线
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。