设置网络的tabbar图片,需要根据系统重新设置尺寸和渲染方式

[[ToolsObject image:image resizeTo:CGSizeMake(24, 24)] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]

 

/// 根据系统修改图片尺寸

/// @param img 原图

/// @param size 新尺寸

+ (UIImage *)image:(UIImage*)img resizeTo:(CGSize)size {

    CGFloat scale = [[UIScreen mainScreen]scale];

    //UIGraphicsBeginImageContext(newSize);

    UIGraphicsBeginImageContextWithOptions(size, NO, scale);

    [img drawInRect:CGRectMake(0,0,size.width,size.height)];

    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return newImage;

}

 

posted on 2021-12-28 11:35  直到所有灯都熄灭了  阅读(28)  评论(0编辑  收藏  举报