TextBox
TextBox
is a layer that contains text that is flowed into the designated frame, breaking lines as needed.
Topics
Discussion
Properties
Refer to the properties concepts section for an overview of properties.
|
Set the value of multiple properties by name. |
|
Set property |
|
Create a context manager that allows setting multiple properties in an efficient way. |
Identification
|
Get the name assigned to this layer during |
|
Set |
|
Set |
Geometry
Refer to the geometry concepts section for an overview of geometry.
Get the anchor of the layer. |
|
|
Set the anchor of the layer. |
Get the position of this layer. |
|
|
Set the position of this layer. |
|
Get the size of this layer. |
|
Set the Size of this layer. |
Transformations
Get a list of all transformations. |
|
|
Add a transformation with |
|
Remove the transformation with |
|
Add a translate transformation with |
|
Add a scale transformation with |
|
Add a rotation transformation with |
|
Add a skew transformation with |
|
Add a transformation with |
Remove the transformation with |
|
Add a sublayer translate transformation with |
|
|
Add a sublayer scale transformation with |
|
Add a sublayer scale transformation with |
|
Add a sublayer skew transformation with |
Frame
Get if the layer is visible. |
|
|
Set if the layer is visible. |
Get if the layer hides any sublayer data outside of its frame. |
|
|
set if the layer hides any sublayer data outside of its frame. |
Get the opacity of this layer. |
|
|
Set the opacity of this layer, |
Get the background color for this layer. |
|
|
Set the background color for this layer. |
Get the border color for this layer. |
|
|
Set the border color for this layer. |
Get the border width for this layer. |
|
|
Set the border width for this layer. |
Get this corner radius of this layer. |
|
|
Set the corner radius of this layer. |
- TextBox.getPadding()
Get the padding for this layer.
- TextBox.setPadding(value)
Set the padding between the edge of the frame and the text for this layer.
padding
should be a tuple of two numbers representing horizontal and vertical values.textBoxLayer = container.appendTextBoxSublayer( position=(50, 50), size=(400, 100), backgroundColor=(1, 1, 0, 1), text="Merz " * 28, pointSize=10, fillColor=(1, 0, 0, 1) ) textBoxLayer.setPadding((100, 25))
Shadow
Get the shadow color for this layer. |
|
|
Set the shadow color for this layer. |
Get the shadow opacity for this layer. |
|
|
Set the shadow opacity for this layer. |
Get the shadow offset for this layer. |
|
|
Set the shadow offset for this layer. |
Get the shadow blur radius for this layer. |
|
|
Set the shadow blur radius for this layer. |
Filters
Refer the filter documentation in Base for complete details.
Set the compositing filter for the layer. |
|
|
Set the compositing filter for the layer. |
Get a list of the filters for this layer. |
|
|
Set a list of the filters for this layer. |
|
Append a filter to this layer. |
|
Get the filter with |
|
Remove the filter with |
Clear all background filters from this layer. |
|
Get a list of the background filters for this layer. |
|
|
Set a list of the background filters for this layer. |
|
Append a background filter to this layer. |
|
Get the background filter with |
|
Remove the background filter with |
Text
- TextBox.getText()
Get the text for this layer.
- TextBox.setText(text)
Set the text for this layer.
text
can be either astring
or an Attributed String.textBoxLayer = container.appendTextBoxSublayer( position=(50, 50), size=(400, 100), backgroundColor=(1, 1, 0, 1), fillColor=(1, 0, 0, 1) ) textBoxLayer.setText("Merz")
textBoxLayer = container.appendTextBoxSublayer( position=(50, 50), size=(400, 100), backgroundColor=(1, 1, 0, 1), pointSize=30, fillColor=(1, 0, 0, 1) ) textBoxLayer.setText( [ dict( text="Merz ", weight="black" ), dict( text="Merz ", font="Courier", pointSize=20, fillColor=(0, 0, 1, 1) ), "Merz " * 5 ] )
- TextBox.getFillColor()
Get the fill color for this layer.
- TextBox.setFillColor(color)
Set the fill color for this layer.
Animatable.
textBoxLayer = container.appendTextBoxSublayer( position=(50, 50), size=(400, 100), text="Merz", backgroundColor=(1, 1, 0, 1) ) textBoxLayer.setFillColor((0, 0, 1, 1))
Font
- TextBox.getFont()
Get the name of the font for this layer.
- TextBox.setFont(name)
Set the name of the font for this layer. If the name is
"system"
the system font will be used.textBoxLayer = container.appendTextBoxSublayer( position=(50, 50), size=(400, 100), text="Merz", backgroundColor=(1, 1, 0, 1), fillColor=(1, 0, 0, 1) ) textBoxLayer.setFont("Courier")
- TextBox.getWeight()
Get the weight of the font in the layer.
- TextBox.setWeight(value)
Set the weight of the font in the layer. This only applies to system fonts. The options are:
"thin"
"ultralight"
"light"
"regular"
"medium"
"semibold"
"bold"
"heavy"
"black"
textBoxLayer = container.appendTextBoxSublayer( position=(50, 50), size=(400, 100), text="Merz", backgroundColor=(1, 1, 0, 1), fillColor=(1, 0, 0, 1) ) textBoxLayer.setWeight("black")
- TextBox.getFigureStyle()
Get the figure style.
- TextBox.setFigureStyle(value)
Set the figure style. This only applies to system fonts. The options are:
"regular"
"tabular"
textBoxLayer = container.appendTextBoxSublayer( position=(50, 50), size=(400, 100), text="0123456789", fillColor=(1, 0, 0, 1), backgroundColor=(1, 1, 0, 1) ) textBoxLayer.setFigureStyle("tabular")
Point Size
- TextBox.getPointSize()
Get the point size for this layer.
- TextBox.setPointSize(value)
Set the point size for this layer.
Animatable.
textBoxLayer = container.appendTextBoxSublayer( position=(50, 50), size=(400, 100), backgroundColor=(1, 1, 0, 1), text="Merz " * 50, fillColor=(1, 0, 0, 1) ) textBoxLayer.setPointSize(15)
- TextBox.getPointSizeIsVisuallyConstant()
Get if the point size for this layer should always visually be the value of
pointSize
.
- TextBox.setPointSizeIsVisuallyConstant(value)
Set if the point size for this layer should always visually be the value of
pointSize
.
Alignment
- TextBox.getHorizontalAlignment()
Get the horizontal alignment for this layer.
- TextBox.setHorizontalAlignment(value)
Set the horizontal alignment for this layer. The options are:
"left"
"right"
"center"
textBoxLayer = container.appendTextBoxSublayer( position=(50, 50), size=(400, 100), text="Merz", fillColor=(1, 0, 0, 1), backgroundColor=(1, 1, 0, 1) ) textBoxLayer.setHorizontalAlignment("right")
Animation
Refer to the animation concepts section for an overview of animation.
Remove all animations from this layer. |
|
|
Stop the animation with the |
Get if animation is currently paused for this layer. |
|
Pause the animation of this layer. |
|
Resume the animation of the layer. |
Sublayers
Refer to the layer hierarchy concepts section for an overview of sublayers.
|
Place a hold on adding the sublayers to this layer’s CALayer until the context manager exits. |
Get all sublayers within this layer. |
|
|
Get the sublayer with |
Remove all sublayers within this layer. |
|
|
Remove the given sublayer from the layer. |
|
Append an instantiated sublayer to this layer. |
|
Append a sublayer to this layer. |
|
Append a base layer. |
|
Append a path layer. |
|
Append a line layer. |
|
Append a oval layer. |
|
Append a rectangle layer. |
|
Append an image layer. |
|
Append a text box. |
|
Append a text line. |
|
Append a symbol. |
|
This creates a context manager that provides a sublayer creation syntax that supports a subset of the DrawBot API. |
Superlayers
Refer to the layer hierarchy concepts section for an overview of superlayers.
Get the Container that this layer belongs to. |
|
Get the layer that this layer belongs to. |
Hit Testing
CoreAnimation Object
Get the CALayer that this object wraps. |