刚接触ios,看到富文本特效,想做一个demo,根据富文本内容,生成一张图片,并保存到本地,结果字符背景色死活不生效,下面是我的测试代码,请高手们解救我这个菜鸟
-(UIImage*)creatImage3 : (int)width andHeight:(int) height andTextContent:(NSAttributedString*)content
{
UIColor *backgroundColor = [UIColor greenColor]; //字符背景色,就是这个没有生效
UIColor *foregroundColor = [UIColor redColor]; //文字前景色,这个生效了
NSDictionary *attrsDic = @{NSForegroundColorAttributeName: foregroundColor,
NSBackgroundColorAttributeName: backgroundColor
};
NSAttributedString *attributedString_str_atts = [[NSAttributedString alloc] initWithString:@"http://www.baidu.com" attributes:attrsDic];
UIGraphicsBeginImageContextWithOptions( CGSizeMake(width, height), NO, 1);
//获取bitmap上下文
CGContextRef context &#