我正在尝试使用此代码将文本写入CGContext
NSString *text = NSLocalizedString(@"myText", nil);
NSDictionary *atributes = @{
NSFontAttributeName : @"Helvetica Neue Bold",
NSForegroundColorAttributeName : [UIColor blackColor]
};
[text drawAtPoint:CGPointMake(x1, y2) withAttributes: attributes];
但我看到了这个错误
由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [__ NSCFConstantString pointSize]:无法识别的选择器发送到实例0x1001dfd40
任何线索?
答案 0 :(得分:2)
为UIFont
设置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];