Reputation: 35933
I am trying to write a text to a CGContext using this code
NSString *text = NSLocalizedString(@"myText", nil);
NSDictionary *atributes = @{
NSFontAttributeName : @"Helvetica Neue Bold",
NSForegroundColorAttributeName : [UIColor blackColor]
};
[text drawAtPoint:CGPointMake(x1, y2) withAttributes: attributes];
but I am seeing this error
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString pointSize]: unrecognized selector sent to instance 0x1001dfd40
any clues?
Upvotes: 0
Views: 124
Reputation: 51911
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];
Upvotes: 2