One Logo Pool Ball
PaperKit · IOS API REFERENCE

ShapeMarkup

struct · iOS 27.0+ · SDK 27.1

struct ShapeMarkup

A markup element that represents a shape or text box with customizable appearance and behavior. Use `ShapeMarkup` to add geometric shapes, lines, and text containers to your markup content. Shapes can be filled, stroked, rotated, and configured with various visual properties. ```swift // Create a filled rectangle let rect = ShapeMarkup( shape: .rectangle, frame: CGRect(x: 0, y: 0, width: 100, height: 50), fillColor: CGColor(red: 0, green: 0, blue: 1, alpha: 1) ) // Create a resizable textbox var textBox = ShapeMarkup( shape: .rectangle, frame: CGRect(x: 0, y: 0, width: 80, height: 80), attributedText: AttributedString("Star!"), autoresizing: [.flexibleWidth] ) textBox.attributedText = AttributedString("This text will cause the box to expand") // Create an arrow line let arrow = ShapeMarkup( shape: .line(start: .zero, control: CGPoint(x: 0.5, y: 0), end: CGPoint(x: 1, y: 0)), frame: CGRect(x: 0, y: 0, width: 200, height: 2), strokeColor: CGColor(red: 0, green: 0, blue: 0, alpha: 1), endLineMarker: .arrow ) ```

Members (33)

get · iOS 27.0+

featureSet

TypeScript
get featureSet(): FeatureSet
Swift declaration
var featureSet: FeatureSet { get }

The set of features used by this markup.

get · iOS 27.0+

renderFrame

TypeScript
get renderFrame(): { x: number; y: number; width: number; height: number }
Swift declaration
var renderFrame: CGRect { get }

The unrotated frame that tightly fits the rendered contents of the element. This frame includes padding around `frame` to ensure it includes all the rendered aspects of the content. For example, this frame will include the strokes, and shadows of any contents.

get · iOS 27.0+

shapeScaled

TypeScript
get shapeScaled(): ShapeMarkup_Shape
Swift declaration
var shapeScaled: ShapeMarkup.Shape { get set }

The type of the shape with values scaled to the current frame. Coordinate values are specified in points relative to the shape's `frame`. When you resize the shape, this property's values automatically update to reflect the new dimensions. Use `shape` if you need consistent relative proportions that don't change when resizing. ```swift var shape = ShapeMarkup( shape: .roundedRectangle(cornerRadius: 0.2), frame: CGRect(x: 0, y: 0, width: 100, height: 100) ) // shapeScaled returns .roundedRectangle(cornerRadius: 20.0) // 20 points shape.frame = CGRect(x: 0, y: 0, width: 200, height: 200) // shapeScaled now returns .roundedRectangle(cornerRadius: 40.0) // 40 points ```

set · iOS 27.0+

shapeScaled

TypeScript
set shapeScaled(value: ShapeMarkup_Shape)
Swift declaration
var shapeScaled: ShapeMarkup.Shape { get set }

The type of the shape with values scaled to the current frame. Coordinate values are specified in points relative to the shape's `frame`. When you resize the shape, this property's values automatically update to reflect the new dimensions. Use `shape` if you need consistent relative proportions that don't change when resizing. ```swift var shape = ShapeMarkup( shape: .roundedRectangle(cornerRadius: 0.2), frame: CGRect(x: 0, y: 0, width: 100, height: 100) ) // shapeScaled returns .roundedRectangle(cornerRadius: 20.0) // 20 points shape.frame = CGRect(x: 0, y: 0, width: 200, height: 200) // shapeScaled now returns .roundedRectangle(cornerRadius: 40.0) // 40 points ```

get · iOS 27.0+

strokeColor

TypeScript
get strokeColor(): (_CoreGraphics_CGColor) | null
Swift declaration
var strokeColor: CGColor? { get set }

The color used to stroke the shape’s path.

set · iOS 27.0+

strokeColor

TypeScript
set strokeColor(value: (_CoreGraphics_CGColor) | null)
Swift declaration
var strokeColor: CGColor? { get set }

The color used to stroke the shape’s path.

get · iOS 27.0+

autoresizing

TypeScript
get autoresizing(): MarkupAutoresizing
Swift declaration
var autoresizing: MarkupAutoresizing { get set }

Automatic sizing behaviors for this markup. Controls whether the markup automatically adjusts its dimensions to fit content changes. - Note: The layout mode (centered vs. top-anchored) is decided at init time and preserved across reassignment; setting `.flexibleHeight` here on a shape that didn't have `.flexibleHeight` at init will use the legacy top-anchored layout. New shapes should express the mode through `init(...autoresizing:)` instead.

set · iOS 27.0+

autoresizing

TypeScript
set autoresizing(value: MarkupAutoresizing)
Swift declaration
var autoresizing: MarkupAutoresizing { get set }

Automatic sizing behaviors for this markup. Controls whether the markup automatically adjusts its dimensions to fit content changes. - Note: The layout mode (centered vs. top-anchored) is decided at init time and preserved across reassignment; setting `.flexibleHeight` here on a shape that didn't have `.flexibleHeight` at init will use the legacy top-anchored layout. New shapes should express the mode through `init(...autoresizing:)` instead.

init · iOS 27.0+

init

TypeScript
static initConfigurationFrameRotation(configuration: ShapeConfiguration, frame: { x: number; y: number; width: number; height: number }, rotation?: number): ShapeMarkup
Swift declaration
init(configuration: ShapeConfiguration, frame: CGRect, rotation: CGFloat = 0.0)

Initializes and returns a new shape markup from the specified parameters. - Parameters: - configuration: The configuration of the shape. - frame: The frame of the shape. - rotation: The rotation in radians of the shape. Defaults to `0.0` (no rotation).

get · iOS 27.0+

endLineMarker

TypeScript
get endLineMarker(): ShapeMarkup_LineMarker
Swift declaration
var endLineMarker: ShapeMarkup.LineMarker { get set }

The line marker used at the end of an open shape path. Line markers are only visible on open paths. Use `shape.supportsLineMarkers` to check whether the current shape supports line markers. Closed shapes like `.rectangle` and `.ellipse` ignore this property. Default is `.none`.

set · iOS 27.0+

endLineMarker

TypeScript
set endLineMarker(value: ShapeMarkup_LineMarker)
Swift declaration
var endLineMarker: ShapeMarkup.LineMarker { get set }

The line marker used at the end of an open shape path. Line markers are only visible on open paths. Use `shape.supportsLineMarkers` to check whether the current shape supports line markers. Closed shapes like `.rectangle` and `.ellipse` ignore this property. Default is `.none`.

get · iOS 27.0+

attributedText

TypeScript
get attributedText(): _Foundation_AttributedString
Swift declaration
var attributedText: AttributedString { get set }

The attributed text displayed inside this shape. The attributed string supports: `.font`, `.foregroundColor`, `.underlineStyle`, `.strikethroughStyle` and writing direction and alignment from `.paragraphStyle`.

set · iOS 27.0+

attributedText

TypeScript
set attributedText(value: _Foundation_AttributedString)
Swift declaration
var attributedText: AttributedString { get set }

The attributed text displayed inside this shape. The attributed string supports: `.font`, `.foregroundColor`, `.underlineStyle`, `.strikethroughStyle` and writing direction and alignment from `.paragraphStyle`.

get · iOS 27.0+

startLineMarker

TypeScript
get startLineMarker(): ShapeMarkup_LineMarker
Swift declaration
var startLineMarker: ShapeMarkup.LineMarker { get set }

The line marker used at the start of an open shape path. Line markers are only visible on open paths. Use `shape.supportsLineMarkers` to check whether the current shape supports line markers. Closed shapes like `.rectangle` and `.ellipse` ignore this property. Default is `.none`.

set · iOS 27.0+

startLineMarker

TypeScript
set startLineMarker(value: ShapeMarkup_LineMarker)
Swift declaration
var startLineMarker: ShapeMarkup.LineMarker { get set }

The line marker used at the start of an open shape path. Line markers are only visible on open paths. Use `shape.supportsLineMarkers` to check whether the current shape supports line markers. Closed shapes like `.rectangle` and `.ellipse` ignore this property. Default is `.none`.

get · iOS 27.0+

allowedInteractions

TypeScript
get allowedInteractions(): MarkupInteractions
Swift declaration
var allowedInteractions: MarkupInteractions { get set }

Interactions that people can perform on this markup. Use this to configure how people can interact with the markup, such as preventing resizing, rotation, or deletion. The default is `.all`, which allows all interactions. Set to `.readOnly` to prevent all modifications.

set · iOS 27.0+

allowedInteractions

TypeScript
set allowedInteractions(value: MarkupInteractions)
Swift declaration
var allowedInteractions: MarkupInteractions { get set }

Interactions that people can perform on this markup. Use this to configure how people can interact with the markup, such as preventing resizing, rotation, or deletion. The default is `.all`, which allows all interactions. Set to `.readOnly` to prevent all modifications.

method · iOS 27.0+

removeContentUnsupported

TypeScript
removeContentUnsupported(featureSet: FeatureSet): boolean
Swift declaration
mutating func removeContentUnsupported(by featureSet: FeatureSet) -> Bool

Removes all content not supported by the provided feature set. - Parameter featureSet: The feature set to limit this markup to. - Returns: True if this was successful and the feature set is now supported. If the returned value is `true` then `self.featureSet.isSubset(of: featureSet)` will be `true`.

get · iOS 27.0+

id

TypeScript
get id(): MarkupID<ShapeMarkup>
Swift declaration
var id: MarkupID<ShapeMarkup>

Stable unique identity of the markup.

set · iOS 27.0+

id

TypeScript
set id(value: MarkupID<ShapeMarkup>)
Swift declaration
var id: MarkupID<ShapeMarkup>

Stable unique identity of the markup.

get · iOS 27.0+

frame

TypeScript
get frame(): { x: number; y: number; width: number; height: number }
Swift declaration
var frame: CGRect { get set }

The element's unrotated frame. Together with `rotation` this defines the element's position in its parent. This won't necessarily contain all the contents of an element, rotation and styling may cause the element to extend beyond this frame. Use `renderFrame` for an unrotated frame that contains the entire element.

set · iOS 27.0+

frame

TypeScript
set frame(value: { x: number; y: number; width: number; height: number })
Swift declaration
var frame: CGRect { get set }

The element's unrotated frame. Together with `rotation` this defines the element's position in its parent. This won't necessarily contain all the contents of an element, rotation and styling may cause the element to extend beyond this frame. Use `renderFrame` for an unrotated frame that contains the entire element.

init · iOS 27.0+

init

TypeScript
static initShapeFrameRotationFillColorStrokeColorLineWidthOpacityStartLineMarkerEndLineMarkerAttributedTextAllowedInteractionsAutoresizingId(shape: ShapeMarkup_Shape, frame: { x: number; y: number; width: number; height: number }, rotation?: number, fillColor?: (_CoreGraphics_CGColor) | null, strokeColor?: (_CoreGraphics_CGColor) | null, lineWidth?: number, opacity?: number, startLineMarker?: ShapeMarkup_LineMarker, endLineMarker?: ShapeMarkup_LineMarker, attributedText?: _Foundation_AttributedString, allowedInteractions?: MarkupInteractions, autoresizing?: MarkupAutoresizing, id?: MarkupID<ShapeMarkup>): ShapeMarkup
Swift declaration
init(shape: ShapeMarkup.Shape, frame: CGRect, rotation: CGFloat = 0.0, fillColor: CGColor? = nil, strokeColor: CGColor? = nil, lineWidth: CGFloat = 1.0, opacity: CGFloat = 1.0, startLineMarker: ShapeMarkup.LineMarker = .none, endLineMarker: ShapeMarkup.LineMarker = .none, attributedText: AttributedString = Foundation.AttributedString(), allowedInteractions: MarkupInteractions = .all, autoresizing: MarkupAutoresizing = [], id: MarkupID<ShapeMarkup> = MarkupID())

Initializes and returns a new shape markup from the specified parameters. - Parameters: - shape: The shape to create. - frame: The frame of the shape. - rotation: The rotation in radians of the shape. Defaults to `0.0` (no rotation). - fillColor: The fill color of the shape. Defaults to `nil` (no fill). - strokeColor: The stroke color of the shape's outline. Defaults to `nil` (no stroke). - lineWidth: The width of the shape's stroke. Defaults to `1.0`. - opacity: The opacity of the shape, ranging from `0.0` (fully transparent) to `1.0` (fully opaque). Defaults to `1.0`. - startLineMarker: The marker style for the start of the line. Defaults to `.none`. Only applicable for open shape paths. - endLineMarker: The marker style for the end of the line. Defaults to `.none`. Only applicable for open shape paths. - attributedText: The attributed text displayed inside this shape. Defaults to the empty string. - allowedInteractions: The flags controlling the interactions users can perform. Defaults to `.all`. - autoresizing: The flags controlling autoresize behavior. Defaults to `[]`. - id: The identity of the shape. Defaults to a unique id.

get · iOS 27.0+

shape

TypeScript
get shape(): ShapeMarkup_Shape
Swift declaration
var shape: ShapeMarkup.Shape { get set }

The type of the shape. The coordinate values of the shape type are relative to the unit coordinate space. For example a corner radius of `0.1` is equivalent to a radius of 10% of the minimum dimension of the shape. Use `shapeScaled` for a shape type with scaled values relative to the shape's `frame`.

set · iOS 27.0+

shape

TypeScript
set shape(value: ShapeMarkup_Shape)
Swift declaration
var shape: ShapeMarkup.Shape { get set }

The type of the shape. The coordinate values of the shape type are relative to the unit coordinate space. For example a corner radius of `0.1` is equivalent to a radius of 10% of the minimum dimension of the shape. Use `shapeScaled` for a shape type with scaled values relative to the shape's `frame`.

get · iOS 27.0+

opacity

TypeScript
get opacity(): number
Swift declaration
var opacity: CGFloat { get set }

The opacity of the shape. Ranges from `0.0` (fully transparent) to `1.0` (fully opaque). Defaults to `1.0`.

set · iOS 27.0+

opacity

TypeScript
set opacity(value: number)
Swift declaration
var opacity: CGFloat { get set }

The opacity of the shape. Ranges from `0.0` (fully transparent) to `1.0` (fully opaque). Defaults to `1.0`.

get · iOS 27.0+

rotation

TypeScript
get rotation(): number
Swift declaration
var rotation: CGFloat { get set }

The element's rotation around the center of its frame. Together with `frame` this defines the element's position in its parent.

set · iOS 27.0+

rotation

TypeScript
set rotation(value: number)
Swift declaration
var rotation: CGFloat { get set }

The element's rotation around the center of its frame. Together with `frame` this defines the element's position in its parent.

get · iOS 27.0+

fillColor

TypeScript
get fillColor(): (_CoreGraphics_CGColor) | null
Swift declaration
var fillColor: CGColor? { get set }

The color used to fill the shape’s path.

set · iOS 27.0+

fillColor

TypeScript
set fillColor(value: (_CoreGraphics_CGColor) | null)
Swift declaration
var fillColor: CGColor? { get set }

The color used to fill the shape’s path.

get · iOS 27.0+

lineWidth

TypeScript
get lineWidth(): number
Swift declaration
var lineWidth: CGFloat { get set }

The line width of the shape’s path.

set · iOS 27.0+

lineWidth

TypeScript
set lineWidth(value: number)
Swift declaration
var lineWidth: CGFloat { get set }

The line width of the shape’s path.

Skipped declarations

No declarations were skipped in this snapshot.

All PaperKit types →