去除tabbar顶部的线条(包含iOS 13之后的处理)
if (@available(iOS 13, *)) {
UITabBarAppearance *appearance = [self.tabBar.standardAppearance copy];
appearance.backgroundImage = [UIColor GC_imageWithColor:GCColorWhite255];
appearance.shadowImage = [UIColor GC_imageWithColor:GCColorWhite255];
// 重置背景和阴影为透明 如果设置了阴影效果则此代码需要去掉
// [appearance configureWithTransparentBackground];
self.tabBar.standardAppearance = appearance;
} else {
self.tabBar.backgroundImage = [UIImage new];
self.tabBar.shadowImage = [UIImage new];
}
备注: GCColorWhite255为 UIColorRGB(255, 255, 255)
//生成图片
+ (UIImage *)GC_imageWithColor:(GCColor)type
{
NSString *key = [NSString stringWithFormat:@"%ld", (long)type];
static NSMutableDictionary *dict = nil;
if (dict == nil) {
dict = [[NSMutableDictionary alloc] init];
}
UIImage *image = [dict objectForKey:key];
if (image == nil) {
image = [UIImage cfa_imageWithColor:[self GC_colorForType:type] size:CGSizeMake(1,1)];
[dict setObject:image forKey:key];
}
return image;
}