CATextLayer Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/QuartzCore.framework |
| Availability | Available in iOS 3.2 and later. |
| Declared in | CATextLayer.h |
| Companion guides | |
Overview
The CATextLayer provides simple text layout and rendering of plain or attributed strings. The first line is aligned to the top of the layer.
Tasks
Getting and Setting the Text
-
stringproperty
Text Visual Properties
-
fontproperty -
fontSizeproperty -
foregroundColorproperty
Text Alignment and Truncation
-
wrappedproperty -
alignmentModeproperty -
truncationModeproperty
Properties
alignmentMode
Determines how individual lines of text are horizontally aligned within the receiver’s bounds.
Discussion
The possible values are described in “Horizontal alignment modes”. Defaults to kCAAlignmentNatural.
Availability
- Available in iOS 3.2 and later.
Declared In
CATextLayer.hfont
The font used to render the receiver’s text.
Discussion
May be either a CTFontRef, a CGFontRef, an instance of NSFont (OS X only), or a string naming the font. In iOS, you cannot assign a UIFont object to this property. Defaults to Helvetica.
The font property is only used when the string property is not an NSAttributedString.
Availability
- Available in iOS 3.2 and later.
Declared In
CATextLayer.hfontSize
The font size used to render the receiver’s text. Animatable.
Discussion
Defaults to 36.0.
The fontSize property is only used when the string property is not an NSAttributedString.
Availability
- Available in iOS 3.2 and later.
Declared In
CATextLayer.hforegroundColor
The color used to render the receiver’s text. Animatable.
Discussion
Defaults to opaque white.
The foregroundColor property is only used when the string property is not an NSAttributedString.
Availability
- Available in iOS 3.2 and later.
Declared In
CATextLayer.hstring
The text to be rendered by the receiver.
Discussion
The text must be an instance of NSString or NSAttributedString. Defaults to nil.
Availability
- Available in iOS 3.2 and later.
Declared In
CATextLayer.htruncationMode
Determines how the text is truncated to fit within the receiver’s bounds.
Discussion
The possible values are described in “Truncation modes”. Defaults to kCATruncationNone.
Availability
- Available in iOS 3.2 and later.
Declared In
CATextLayer.hwrapped
Determines whether the text is wrapped to fit within the receiver’s bounds.
Discussion
Defaults to NO.
Availability
- Available in iOS 3.2 and later.
Declared In
CATextLayer.hConstants
Truncation modes
These constants are used by the truncationMode property.
NSString * const kCATruncationNone; NSString * const kCATruncationStart; NSString * const kCATruncationEnd; NSString * const kCATruncationMiddle;
Constants
kCATruncationNoneIf the
wrappedproperty isYES, the text is wrapped to the receiver’s bounds, otherwise the text is clipped to the receiver’s bounds.Available in iOS 3.2 and later.
Declared in
CATextLayer.h.kCATruncationStartEach line is displayed so that the end fits in the container and the missing text is indicated by some kind of ellipsis glyph.
Available in iOS 3.2 and later.
Declared in
CATextLayer.h.kCATruncationEndEach line is displayed so that the beginning fits in the container and the missing text is indicated by some kind of ellipsis glyph.
Available in iOS 3.2 and later.
Declared in
CATextLayer.h.kCATruncationMiddleEach line is displayed so that the beginning and end fit in the container and the missing text is indicated by some kind of ellipsis glyph in the middle.
Available in iOS 3.2 and later.
Declared in
CATextLayer.h.
Declared In
CATextLayer.hHorizontal alignment modes
These constants are used by the alignmentMode property.
NSString * const kCAAlignmentNatural; NSString * const kCAAlignmentLeft; NSString * const kCAAlignmentRight; NSString * const kCAAlignmentCenter; NSString * const kCAAlignmentJustified;
Constants
kCAAlignmentNaturalUse the natural alignment of the text’s script.
Available in iOS 3.2 and later.
Declared in
CATextLayer.h.kCAAlignmentLeftText is visually left aligned.
Available in iOS 3.2 and later.
Declared in
CATextLayer.h.kCAAlignmentRightText is visually right aligned.
Available in iOS 3.2 and later.
Declared in
CATextLayer.h.kCAAlignmentCenterText is visually center aligned.
Available in iOS 3.2 and later.
Declared in
CATextLayer.h.kCAAlignmentJustifiedText is justified.
Available in iOS 3.2 and later.
Declared in
CATextLayer.h.
Declared In
CATextLayer.h© 2010 Apple Inc. All Rights Reserved. (Last updated: 2010-05-24)