在CGContext中写一个NSString,总是黑色

时间:2014-10-18 17:13:13

标签: ios cocoa nsstring cgcontext uicolor

我尝试在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();

我将文本设置为白色时缺少什么?
谢谢。

0 个答案:

没有答案