Search Docs
Loading...
Skip to content

Create a Color Palette

Customize the editor’s color palette so every fill, stroke, and color-aware control picks from the same brand-approved colors.

Editor showing the custom color palette in the fill picker

3 mins
estimated time
GitHub

The example wraps the editor in GuideEditorConfiguration, a small helper class the iOS guides repository ships as a minimal baseline. Substitute your own editor configuration class — the colorPalette(_:) builder method is exposed on every configuration, so the rest of the call stays the same.

Defining the Palette#

The palette is an array of NamedColor values. Each entry pairs an accessibility name — used as the VoiceOver label for the swatch — with the CGColor displayed in the picker.

Provide exactly seven entries. How many swatches actually render depends on the picker:

  • Six swatches appear in pickers that support a “no color” state (Fill, Stroke, and similar controls that can be disabled). The seventh slot is taken by a No Color button, so only the first six entries from your palette are drawn. The hero above shows this layout.
  • Seven swatches appear in pickers that always require a color (for example, Text Color), where no No Color button is shown.

Order the array so the most important colors come first — entries past the sixth position only surface in the second case.

static let palette: [NamedColor] = [
.init("Blue", .imgly.blue),
.init("Green", .imgly.green),
.init("Yellow", .imgly.yellow),
.init("Red", .imgly.red),
.init("Black", .imgly.black),
.init("White", .imgly.white),
.init("Gray", .imgly.gray),
]

The example uses the IMG.LY system colors (.imgly.blue, .imgly.green, .imgly.yellow, .imgly.red, .imgly.black, .imgly.white, .imgly.gray). Any CGColor works — substitute your brand colors or values derived from UIColor.

Applying the Palette#

Define the array somewhere your editor configuration can reach it — the example uses a static let palette on the SwiftUI view — and pass it via builder.colorPalette(_:) inside the editor configuration. The new colors take effect in every CE.SDK color-aware control — Fill, Stroke, Text Color, and similar pickers. The palette is not exposed to app code, so custom UI you build alongside the editor should reference your own NamedColor array directly instead of trying to read the configured palette back.

Editor(settings)
.imgly.configuration {
GuideEditorConfiguration { builder in
builder.colorPalette(Self.palette)
}
}

API Reference#

SymbolDescription
EditorConfiguration.Builder.colorPalette(_:)Sets the palette of NamedColor values used by CE.SDK’s built-in color pickers.
NamedColor(_:_:)Pairs a VoiceOver accessibility name with a CGColor.
CGColor.imgly.*IMG.LY-defined system colors (blue, green, yellow, red, black, white, gray).

Next Steps#

  • Color Basics — Review the three color spaces CE.SDK supports and when to use each
  • Apply Colors — Apply colors to design elements programmatically
  • CMYK Colors — Work with CMYK for print workflows
  • Spot Colors — Define and manage spot colors for specialized printing