+ (UIImage*)imageWithIcon:(NSString*)iconCode size:(NSUInteger)size color:(UIColor*)color fontSize:(NSInteger)font {
CGSize imageSize = CGSizeMake(size, size);
UIGraphicsBeginImageContextWithOptions(imageSize, NO, [[UIScreen mainScreen] scale]);
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, size, size)];
label.font = [UIFont systemFontOfSize:kWidthScale(font)];
label.text = iconCode;
if(color){
label.textColor = color;
}
label.textAlignment = NSTextAlignmentCenter;
label.numberOfLines = 0;
[label.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *retImage = UIGraphicsGetImageFromCurrentImageContext();
return retImage;
}
文字转图片
最新推荐文章于 2024-08-28 09:23:05 发布