NSStringDrawingContext Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/UIKit.framework |
| Availability | Available in iOS 6.0 and later. |
| Declared in | NSStringDrawing.h |
Overview
The NSStringDrawingContext class manages metrics used when drawing attributed strings. Prior to drawing, you can create an instance of this class and use it to specify the minimum scale factor and tracking adjustments for a string. After drawing, you can retrieve the actual values that were used during drawing.
To use this class, alloc/init a new instance, set the minimum values, and pass your object to one of the corresponding NSAttributedString methods that take the context object as a parameter. Upon completion of drawing, you can use the actual drawing values to make adjustments or record where the string was actually drawn.
Tasks
Accessing the Tracking Adjustments
-
minimumTrackingAdjustmentproperty -
actualTrackingAdjustmentproperty
Accessing the Scale Factors
-
minimumScaleFactorproperty -
actualScaleFactorproperty
Getting the Drawing Bounds
-
totalBoundsproperty
Properties
actualScaleFactor
The actual scale factor that was applied to the font during drawing. (read-only)
Discussion
If you specified a custom value in the minimumScaleFactor property, when drawing is complete, this property contains the actual scale factor value that was used to draw the string.
Availability
- Available in iOS 6.0 and later.
Declared In
NSStringDrawing.hactualTrackingAdjustment
The actual tracking value that was applied during drawing. (read-only)
Discussion
If you specified a custom value in the minimumTrackingAdjustment property, when drawing is complete, this property contains the actual tracking value that was used.
Availability
- Available in iOS 6.0 and later.
Declared In
NSStringDrawing.hminimumScaleFactor
The scale factor that determines the smallest font size to use during drawing.
Discussion
A value of 0.0 corresponds to a scale factor of 1.0. Any value greater than 0.0 is multiplied by the font point size to get the smallest font size that is permissible to use. For example, 0.5 indicates a font that is half the size of the actual font, 0.75 is three-quarters of the font size, and so on. Typically, you specify a value between 0.0 and 1.0 to indicate how much the font can be shrunk during drawing.
The default value of this property is 0.0.
Availability
- Available in iOS 6.0 and later.
Declared In
NSStringDrawing.hminimumTrackingAdjustment
The smallest amount of space (in points) to maintain between characters.
Discussion
Changing the value of this property tells the renderer that it can change the tracking to a value no smaller than the indicated amount. For example, a value of -0.5 indicates that characters can be tracked closer together by up to half a point. A value of 0 indicates that the standard spacing is used. A typical range of values for this property would be -0.5 to 0.0. The default value of this property is 0.0.
Availability
- Available in iOS 6.0 and later.
Declared In
NSStringDrawing.htotalBounds
The bounding rectangle that was last used when drawing the string. (read-only)
Discussion
This property contains the bounding rectangle that was last used when calling the drawWithRect:options:context: method. The rectangle is specified in the coordinate system of the view where the string was drawn.
Availability
- Available in iOS 6.0 and later.
Declared In
NSStringDrawing.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-09-19)