我尝试在Context中编写NSString但无法设置其颜色;它总是以黑色显示:
UIGraphicsBeginImageContext(CGSizeMake(200, 200));
[[UIColor whiteColor] set];
[@"Hello" drawInRect:CGRectMake(0,0, theStringSize.width, theStringSize.height) withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:NSFontAttributeName,[UIFont fontWithName:@"Optima-Italic" size:12],NSForegroundColorAttributeName,[UIColor whiteColor], nil]];
MyImgView.image=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
我将文本设置为白色时缺少什么?
谢谢。