2014-10-17 44 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