| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/QuartzCore.framework |
| Availability | Available in Mac OS X v10.5 and later. |
| Declared in | CATextLayer.h |
| Companion guides | |
| Related sample code |
The CATextLayer provides simple text layout and rendering of plain or attributed strings. The first line is aligned to the top of the layer.
Note: CATextLayer disabled sub-pixel antialiasing when rendering text. Text can only be drawn using sub-pixel antialiasing when it is composited into an existing opaque background at the same time that it's rasterized. There is no way to draw subpixel-antialiased text by itself, whether into an image or a layer, separately in advance of having the background pixels to weave the text pixels into. Setting the opacity property of the layer to YES does not change the rendering mode.
Note: When a CATextLayer instance is positioned using the CAConstraintLayoutManager Class Reference the bounds of the layer is resized to fit the text content.
string property
font property
fontSize property
foregroundColor property
wrapped property
– isWrapped
alignmentMode property
truncationMode property
For more about Objective-C properties, see “Properties” in The Objective-C 2.0 Programming Language.
Determines how individual lines of text are horizontally aligned within the receiver’s bounds.
@property(copy) NSString *alignmentMode
The possible values are described in “Horizontal alignment modes”. Defaults to kCAAlignmentNatural.
CATextLayer.hThe font used to render the receiver’s text.
@property CFTypeRef font
May be either a CTFontRef, a CGFontRef, an instance of NSFont, or a string naming the font. Defaults to Helvetica.
The font property is only used when the string property is not an NSAttributedString.
Note: If the font property specifies a font size (if it is a CTFontRef, a CGFontRef, an instance of NSFont) the font size is ignored.
CATextLayer.hThe font size used to render the receiver’s text.
@property CGFloat fontSize
Defaults to 36.0.
The font property is only used when the string property is not an NSAttributedString.
CATextLayer.hThe color used to render the receiver’s text.
@property CGColorRef foregroundColor
Defaults to opaque white.
The font property is only used when the string property is not an NSAttributedString.
CATextLayer.hThe text to be rendered by the receiver.
@property(copy) id string
The text must be an instance of NSString or NSAttributedString. Defaults to nil.
CATextLayer.hDetermines how the text is truncated to fit within the receiver’s bounds.
@property(copy) NSString *truncationMode
The possible values are described in “Truncation modes”. Defaults to kCATruncationNone.
CATextLayer.hDetermines whether the text is wrapped to fit within the receiver’s bounds.
@property BOOL wrapped
Defaults to NO.
CATextLayer.hA synthesized accessor for the wrapped property.
- (BOOL)isWrapped
These constants are used by the truncationMode property.
NSString * const kCATruncationNone; NSString * const kCATruncationStart; NSString * const kCATruncationEnd; NSString * const kCATruncationMiddle;
kCATruncationNoneIf the wrapped property is YES, the text is wrapped to the receiver’s bounds, otherwise the text is clipped to the receiver’s bounds.
Available in Mac OS X v10.5 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 Mac OS X v10.5 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 Mac OS X v10.5 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 Mac OS X v10.5 and later.
Declared in CATextLayer.h.
CATextLayer.hThese constants are used by the alignmentMode property.
NSString * const kCAAlignmentNatural; NSString * const kCAAlignmentLeft; NSString * const kCAAlignmentRight; NSString * const kCAAlignmentCenter; NSString * const kCAAlignmentJustified;
kCAAlignmentNaturalUse the natural alignment of the text’s script.
Available in Mac OS X v10.5 and later.
Declared in CATextLayer.h.
kCAAlignmentLeftText is visually left aligned.
Available in Mac OS X v10.5 and later.
Declared in CATextLayer.h.
kCAAlignmentRightText is visually right aligned.
Available in Mac OS X v10.5 and later.
Declared in CATextLayer.h.
kCAAlignmentCenterText is visually center aligned.
Available in Mac OS X v10.5 and later.
Declared in CATextLayer.h.
kCAAlignmentJustifiedText is justified.
Available in Mac OS X v10.5 and later.
Declared in CATextLayer.h.
CATextLayer.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-12-11)