This method is deprecated in iOS 7.0:
drawAtPoint:forWidth:withFont:fontSize:lineBreakMode:baselineAdjustment:
Now use drawInRect:withAtt
You can use NSDictionary
and apply attributes like this:
NSFont *font = [NSFont fontWithName:@"Palatino-Roman" size:14.0];
NSDictionary *attrsDictionary =
[NSDictionary dictionaryWithObjectsAndKeys:
font, NSFontAttributeName,
[NSNumber numberWithFloat:1.0], NSBaselineOffsetAttributeName, nil];
Use attrsDictionary
as argument.
Refer: Attributed String Programming Guide
Refer: Standard Attributes
SWIFT: IN String drawInRect is not available but we can use NSString instead:
let font = UIFont(name: "Palatino-Roman", size: 14.0)
let baselineAdjust = 1.0
let attrsDictionary = [NSFontAttributeName:font, NSBaselineOffsetAttributeName:baselineAdjust] as [NSObject : AnyObject]
let str:NSString = "Hello World"
str.drawInRect(CGRectZero, withAttributes: attrsDictionary)