@MainActor @objc @preconcurrency class ImagePlaygroundViewController
Displays a standard system interface to generate images from
the provided input.
Present an ``ImagePlaygroundViewController`` to display a standard
system interface to generate images from a description you provide.
People use the view controller interface to generate images and
experiment with the contents before returning an image to your app.
You can then incorporate that image into your app’s content.
Create an ``ImagePlaygroundViewController`` and configure it with an
initial description of the image you want before you present it.
Specify a text-based description of the image using the ``concepts``
property. If you have a starting image that you want to use to create
the new image, specify your image in the ``sourceImage`` property.
Present this view controller from your interface and wait for it to
deliver results to your custom ``delegate`` object. If the person
approves the image, the view controller sends that image to your app
via this delegate object. The view controller also notifies your
delegate if the person cancels the operation.
Members (24)
get · iOS 18.1+
isAvailable
TypeScript
static get isAvailable(): Promise<boolean>
Swift declaration
@objc(available) nonisolated dynamic class var isAvailable: Bool { get }
A Boolean value that indicates whether image generation
is available on the current device.
The value of this property is `true` when the current device
supports image generation. A device might not support this
feature if the device or system doesn’t have the resources
necessary to generate the images.
Notifies the view controller that its view is about to be removed from a
view hierarchy.
The view controller uses this method to remove its interface configurations.
Called after the controller’s view is loaded into memory.
The view controller uses this method to configure its interface.
get · iOS 18.1+
delegate
TypeScript
get delegate(): Promise<(SDKHandle) | null>
Swift declaration
@MainActor @objc @preconcurrency weak var delegate: (any ImagePlaygroundViewController.Delegate)?
The delegate object that receives the generated image and
handles events from the view controller.
Set the value of this property to a custom type you define.
The view controller reports relevant interactions to your type
using the methods of the ``ImagePlaygroundViewController/Delegate``
protocol. For example, the view controller notifies your
delegate when the person accepts a generated image.
@MainActor @objc @preconcurrency weak var delegate: (any ImagePlaygroundViewController.Delegate)?
The delegate object that receives the generated image and
handles events from the view controller.
Set the value of this property to a custom type you define.
The view controller reports relevant interactions to your type
using the methods of the ``ImagePlaygroundViewController/Delegate``
protocol. For example, the view controller notifies your
delegate when the person accepts a generated image.
get · iOS 18.1+
isModalInPresentation
TypeScript
get isModalInPresentation(): Promise<boolean>
Swift declaration
@MainActor @preconcurrency override dynamic var isModalInPresentation: Bool { get set }
A Boolean value indicating whether the view controller enforces a modal behavior.
The view controller prevents swiping or tapping away its interface if there
are active changes.
@MainActor @preconcurrency override dynamic var isModalInPresentation: Bool { get set }
A Boolean value indicating whether the view controller enforces a modal behavior.
The view controller prevents swiping or tapping away its interface if there
are active changes.
get · iOS 18.1+
modalPresentationStyle
TypeScript
get modalPresentationStyle(): Promise<_UIKit_UIModalPresentationStyle>
Swift declaration
@MainActor @preconcurrency override dynamic var modalPresentationStyle: UIModalPresentationStyle { get set }
The presentation style for modal view controllers.
The view controller overrides this method to establish its preferred presentation
style in visionOS. Changing the value of this property has no effect in visionOS.
@MainActor @preconcurrency override dynamic var modalPresentationStyle: UIModalPresentationStyle { get set }
The presentation style for modal view controllers.
The view controller overrides this method to establish its preferred presentation
style in visionOS. Changing the value of this property has no effect in visionOS.
get · iOS 18.1+
preferredContentSize
TypeScript
get preferredContentSize(): Promise<{ width: number; height: number }>
Swift declaration
@MainActor @preconcurrency override dynamic var preferredContentSize: CGSize { get set }
The preferred size for the view controller’s view.
The view controller overrides this method to establish its preferred content
size in visionOS. Changing the value of this property has no effect in visionOS.
set · iOS 18.1+
preferredContentSize
TypeScript
setPreferredContentSize(value: { width: number; height: number }): Promise<void>
Swift declaration
@MainActor @preconcurrency override dynamic var preferredContentSize: CGSize { get set }
The preferred size for the view controller’s view.
The view controller overrides this method to establish its preferred content
size in visionOS. Changing the value of this property has no effect in visionOS.
get · iOS 18.1+
sourceImage
TypeScript
get sourceImage(): Promise<(_UIKit_UIImage) | null>
Swift declaration
@MainActor @objc @preconcurrency var sourceImage: UIImage? { get set }
An image to use as source input for generating the new image.
If you have an existing image that you want to use as a starting
point for the new image, add it to this property. If you don’t
supply a source image, the system creates the new image from
the prompt text you provide.
Typically, you provide an image big enough to fit the device's display.
The expected minimum size is 384 x 384 pixels, and the recommended
maximum size is 4096 x 4096 pixels.
@MainActor @objc @preconcurrency var sourceImage: UIImage? { get set }
An image to use as source input for generating the new image.
If you have an existing image that you want to use as a starting
point for the new image, add it to this property. If you don’t
supply a source image, the system creates the new image from
the prompt text you provide.
Typically, you provide an image big enough to fit the device's display.
The expected minimum size is 384 x 384 pixels, and the recommended
maximum size is 4096 x 4096 pixels.
get · iOS 18.4+ · Deprecated in iOS 26.4
personalizationPolicy
TypeScript
get personalizationPolicy(): Promise<ImagePlaygroundPersonalizationPolicy>
Swift declaration
@MainActor @preconcurrency var personalizationPolicy: ImagePlaygroundPersonalizationPolicy { get set }
The policy to apply when determining whether to include people in generated images.
Personalization lets the view controller offer support for incorporating people
into the images it generates. When enabled, the view controller allows someone
to build images that include:
* A person from their Photos library
* A character represented by an appearance and a skin tone
When enabled, the view controller offers a way to import an image of
a person from the Photos library. It also supports choosing someone
from a people picker, and by detecting names in any input text and using
that information to find images.
The default value of this property is ``ImagePlaygroundPersonalizationPolicy/automatic``,
which corresponds to ``ImagePlaygroundPersonalizationPolicy/enabled``.
@MainActor @preconcurrency var personalizationPolicy: ImagePlaygroundPersonalizationPolicy { get set }
The policy to apply when determining whether to include people in generated images.
Personalization lets the view controller offer support for incorporating people
into the images it generates. When enabled, the view controller allows someone
to build images that include:
* A person from their Photos library
* A character represented by an appearance and a skin tone
When enabled, the view controller offers a way to import an image of
a person from the Photos library. It also supports choosing someone
from a people picker, and by detecting names in any input text and using
that information to find images.
The default value of this property is ``ImagePlaygroundPersonalizationPolicy/automatic``,
which corresponds to ``ImagePlaygroundPersonalizationPolicy/enabled``.
get · iOS 18.4+
allowedGenerationStyles
TypeScript
get allowedGenerationStyles(): Promise<Array<ImagePlaygroundStyle>>
Swift declaration
@MainActor @preconcurrency var allowedGenerationStyles: [ImagePlaygroundStyle] { get set }
A list of allowed generation styles to choose from in the playground.
Use `ImagePlaygroundStyle/all` to check the list of all possible styles, and pass a subset of those.
The `selectedGenerationStyle` is expected to be included in this list.
@MainActor @preconcurrency var allowedGenerationStyles: [ImagePlaygroundStyle] { get set }
A list of allowed generation styles to choose from in the playground.
Use `ImagePlaygroundStyle/all` to check the list of all possible styles, and pass a subset of those.
The `selectedGenerationStyle` is expected to be included in this list.
get · iOS 18.4+
selectedGenerationStyle
TypeScript
get selectedGenerationStyle(): Promise<ImagePlaygroundStyle>
Swift declaration
@MainActor @preconcurrency var selectedGenerationStyle: ImagePlaygroundStyle { get set }
Generation style to pre-select upong launching the playground among those in `allowedGenerationStyles`.
Use `ImagePlaygroundStyle.all` to check the list of all possible styles, and pass one of those.
@MainActor @preconcurrency var selectedGenerationStyle: ImagePlaygroundStyle { get set }
Generation style to pre-select upong launching the playground among those in `allowedGenerationStyles`.
Use `ImagePlaygroundStyle.all` to check the list of all possible styles, and pass one of those.
get · iOS 26.4+
options
TypeScript
get options(): Promise<ImagePlaygroundOptions>
Swift declaration
@MainActor @preconcurrency var options: ImagePlaygroundOptions { get set }
Options that influence the image-generation process.
To specify custom options, modify the value in this property before you present
the view controller. If you don’t modify this property, the view controller
uses the default set of options.
@MainActor @preconcurrency var options: ImagePlaygroundOptions { get set }
Options that influence the image-generation process.
To specify custom options, modify the value in this property before you present
the view controller. If you don’t modify this property, the view controller
uses the default set of options.
get · iOS 18.1+
concepts
TypeScript
get concepts(): Promise<Array<ImagePlaygroundConcept>>
Swift declaration
@MainActor @preconcurrency var concepts: [ImagePlaygroundConcept] { get set }
An array of elements that describes the expected contents of the image.