美文网首页程序员
iOS修改安全区颜色

iOS修改安全区颜色

作者: 叫我马小帅 | 来源:发表于2020-12-25 09:11 被阅读0次

TabBarController中

- (void)viewDidLoad
 {
    [super viewDidLoad];
    [self.tabBar setBackgroundImage:[self imageWithColor:MainBgColor]];
}

- (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;
}

相关文章

网友评论

    本文标题:iOS修改安全区颜色

    本文链接:https://www.haomeiwen.com/subject/qnlbnktx.html