Contents

ShapeMarkup

A markup element that represents a shape or text box with customizable appearance and behavior.

Declaration

struct ShapeMarkup

Overview

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.

// 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
)

Topics

Creating a shape

Choosing a shape type

Configuring fill and stroke

Configuring text

Configuring line markers

Configuring sizing

Identifying markup

See Also

Markup elements