CCLabelTTF Class Reference
| Inherits from | CCSprite : CCNode : CCResponder : NSObject |
| Conforms to | CCLabelProtocol |
| Declared in | CCLabelTTF.h |
Overview
CCLabelTTF displays a rendered TTF font texture. The label is created from a platform font. Attributed strings are supported on Mac and iOS6+ which allows for greater text formatting control.
Notes
Each time you modify the label text you are effectivley creating a new CCLabelTTF so there may be a performance hit if you need to frequently update the label. In this scenario you should also look at CCLabelBMFont which does not have this overhead.
Resources
- http://iosfonts.com/ (Please use Safari for accurate font rendering)
Tasks
Accessing the Text Attributes
-
stringproperty -
attributedStringproperty -
fontNameproperty -
fontSizeproperty -
fontColorproperty -
horizontalAlignmentproperty -
verticalAlignmentproperty
Sizing the Label
-
dimensionsproperty -
dimensionsTypeproperty -
adjustsFontSizeToFitproperty -
minimumFontSizeproperty -
baselineAdjustmentproperty
Drawing a Shadow
-
shadowColorproperty -
shadowOffsetproperty -
shadowOffsetInPointsproperty -
shadowOffsetTypeproperty -
shadowBlurRadiusproperty
Drawing an Outline
-
outlineColorproperty -
outlineWidthproperty
Creating a CCLabelTTF Object
-
+ labelWithString:fontName:fontSize: -
+ labelWithString:fontName:fontSize:dimensions: -
+ labelWithAttributedString: -
+ labelWithAttributedString:dimensions:
Initializing a CCLabelTTF Object
-
– initWithString:fontName:fontSize: -
– initWithString:fontName:fontSize:dimensions: -
– initWithAttributedString: -
– initWithAttributedString:dimensions: -
– setHTML:
TTF Management
Properties
adjustsFontSizeToFit
If true, the label will be scaled down to fit into the size provided by the dimensions property. Only has an effect if dimensions are set.
@property (nonatomic, assign) BOOL adjustsFontSizeToFitDeclared In
CCLabelTTF.hattributedString
The label attributed text.
@property (nonatomic, copy) NSAttributedString *attributedStringDeclared In
CCLabelTTF.hbaselineAdjustment
Adjusts the fonts baseline, the value is set in points.
@property (nonatomic, assign) CGFloat baselineAdjustmentDeclared In
CCLabelTTF.hdimensions
Dimensions of the label in Points.
@property (nonatomic, assign) CGSize dimensionsDeclared In
CCLabelTTF.hdimensionsType
Dimension type of the label.
@property (nonatomic, assign) CCSizeType dimensionsTypeDeclared In
CCLabelTTF.hfontColor
The color of the text (If not using shadow or outline).
@property (nonatomic, strong) CCColor *fontColorDeclared In
CCLabelTTF.hfontName
The platform font to use for the text.
@property (nonatomic, strong) NSString *fontNameDeclared In
CCLabelTTF.hfontSize
The font size of the text.
@property (nonatomic, assign) CGFloat fontSizeDeclared In
CCLabelTTF.hhorizontalAlignment
The horizontal alignment technique of the text.
@property (nonatomic, assign) CCTextAlignment horizontalAlignmentDeclared In
CCLabelTTF.hminimumFontSize
Used together with adjustsFontSizeToFit. Fonts will not be scaled down below this size (the label will instead be clipped).
@property (nonatomic, assign) CGFloat minimumFontSizeDeclared In
CCLabelTTF.houtlineColor
The color of the text’s outline.
@property (nonatomic, strong) CCColor *outlineColorDeclared In
CCLabelTTF.houtlineWidth
The width of the text’s outline.
@property (nonatomic, assign) CGFloat outlineWidthDeclared In
CCLabelTTF.hshadowBlurRadius
The blur radius of the shadow.
@property (nonatomic, assign) CGFloat shadowBlurRadiusDeclared In
CCLabelTTF.hshadowColor
The color of the text shadow. If the color is transparent, no shadow will be used.
@property (nonatomic, strong) CCColor *shadowColorDeclared In
CCLabelTTF.hshadowOffset
The offset of the shadow.
@property (nonatomic, assign) CGPoint shadowOffsetDeclared In
CCLabelTTF.hshadowOffsetInPoints
The offset of the shadow in points
@property (nonatomic, readonly) CGPoint shadowOffsetInPointsDeclared In
CCLabelTTF.hClass Methods
labelWithAttributedString:
Creates and returns a label object using the specified attributed text.
+ (id)labelWithAttributedString:(NSAttributedString *)attrStringParameters
- attrString
Label Attributed text.
Return Value
The CCLabelTTF Object.
Availability
Available in iOS 6.0+ and OS X.
Declared In
CCLabelTTF.hlabelWithAttributedString:dimensions:
Creates and returns a label object using the specified attributed text and dimensions.
+ (id)labelWithAttributedString:(NSAttributedString *)attrString dimensions:(CGSize)dimensionsReturn Value
The CCLabelTTF Object.
Availability
Available in iOS 6.0+ and OS X.
Declared In
CCLabelTTF.hlabelWithString:fontName:fontSize:
Creates and returns a label object using the specified text, font name and font size.
+ (id)labelWithString:(NSString *)string fontName:(NSString *)name fontSize:(CGFloat)sizeParameters
- string
Label text.
- name
Label font name.
- size
Label font size (in points).
Return Value
The CCLabelTTF Object.
Declared In
CCLabelTTF.hlabelWithString:fontName:fontSize:dimensions:
Creates and returns a label object using the specified text, font name, font size and dimensions.
+ (id)labelWithString:(NSString *)string fontName:(NSString *)name fontSize:(CGFloat)size dimensions:(CGSize)dimensionsParameters
- string
Label text.
- name
Label font name.
- size
Label font size (in points).
- dimensions
Label dimensions.
Return Value
The CCLabelTTF Object.
Declared In
CCLabelTTF.hInstance Methods
initWithAttributedString:
Initializes and returns a label object using the specified attributed text.
- (id)initWithAttributedString:(NSAttributedString *)attrStringParameters
- attrString
Label Attributed text.
Return Value
An initialized CCLabelTTF Object.
Availability
Available in iOS 6.0+ and OS X.
Declared In
CCLabelTTF.hinitWithAttributedString:dimensions:
Initializes and returns a label object using the specified attributed text and dimensions.
- (id)initWithAttributedString:(NSAttributedString *)attrString dimensions:(CGSize)dimensionsReturn Value
An initialized CCLabelTTF Object.
Availability
Available in iOS 6.0+ and OS X.
Declared In
CCLabelTTF.hinitWithString:fontName:fontSize:
Initializes and returns a label object using the specified text, font name and font size.
- (id)initWithString:(NSString *)string fontName:(NSString *)name fontSize:(CGFloat)sizeParameters
- string
Label text.
- name
Label font name.
- size
Label font size (in points).
Return Value
An initialized CCLabelTTF Object.
Declared In
CCLabelTTF.hinitWithString:fontName:fontSize:dimensions:
Initializes and returns a label object using the specified text, font name, font size and dimensions.
- (id)initWithString:(NSString *)string fontName:(NSString *)name fontSize:(CGFloat)size dimensions:(CGSize)dimensionsParameters
- string
Label text.
- name
Label font name.
- size
Label font size (in points).
- dimensions
Label dimensions.
Return Value
An initialized CCLabelTTF Object.
Declared In
CCLabelTTF.h