2014-10-17 40 views
0

我想使用此代码奇怪的错误书写文字CGContext上

NSString *text = NSLocalizedString(@"myText", nil); 

    NSDictionary *atributes = @{ 
            NSFontAttributeName : @"Helvetica Neue Bold", 
            NSForegroundColorAttributeName : [UIColor blackColor] 
            }; 

    [text drawAtPoint:CGPointMake(x1, y2) withAttributes: attributes]; 

写文本到CGContext上,但我看到这个错误

终止应用程序由于未捕获的异常“NSInvalidArgumentException”,原因:' - [__ NSCFConstantString pointSize]:无法识别的选择器发送到实例0x1001dfd40

任何线索?

回答

2

set UIFont object for NSFontAttributeName

NSString *text = NSLocalizedString(@"myText", nil); 

NSDictionary *atributes = @{ 
          NSFontAttributeName : [UIFont fontWithName:@"Helvetica Neue Bold" size: 17.0], 
          NSForegroundColorAttributeName : [UIColor blackColor] 
          }; 

[text drawAtPoint:CGPointMake(x1, y2) withAttributes: attributes]; 
+0

就是这样!谢谢!!!!!! – SpaceDog 2014-10-17 17:55:04