Rendering

Affect the way the system draws a view, for example by scaling or masking a view, or by applying graphical effects.

Topics

Masking and Clipping Views

func clipped(antialiased: Bool) -> View

Clips this view to its bounding rectangular frame.

func clipShape<S>(S, style: FillStyle) -> View

Sets a clipping shape for this view.

func cornerRadius(CGFloat, antialiased: Bool) -> View

Clips this view to its bounding frame, with the specified corner radius.

func mask<Mask>(Mask) -> View

Masks this view using the alpha channel of the given view.

Scaling Views

func scaledToFill() -> View

Scales the view to fill its parent.

func scaledToFit() -> View

Scales this view to fit its parent.

func scaleEffect(CGFloat, anchor: UnitPoint) -> View

Scales this view’s rendered output by the given amount in both the horizontal and vertical directions, relative to an anchor point.

func scaleEffect(CGSize, anchor: UnitPoint) -> View

Scales this view’s rendered output by the given vertical and horizontal size amounts, relative to an anchor point.

func scaleEffect(x: CGFloat, y: CGFloat, anchor: UnitPoint) -> View

Scales this view’s rendered output by the given horizontal and vertical amounts, relative to an anchor point.

func aspectRatio(CGFloat?, contentMode: ContentMode) -> View

Constrains the view’s dimensions to the specified aspect ratio.

func aspectRatio(CGSize, contentMode: ContentMode) -> View

Constrains the view’s dimensions to the aspect ratio of the specified size.

enum ContentMode

Constants that define how a view's content fills the available space.

func imageScale(Image.Scale) -> View

Scales images within the view according to one of the relative sizes available including small, medium, and large images sizes.

Rotating and Transforming Views

func rotationEffect(Angle, anchor: UnitPoint) -> View

Rotates this view’s rendered output around the specified point.

func projectionEffect(ProjectionTransform) -> View

Applies a projection transformation to this view’s rendered output.

func transformEffect(CGAffineTransform) -> View

Applies an affine transformation to this view’s rendered output.

Applying Graphical Effects to a View

func blur(radius: CGFloat, opaque: Bool) -> View

Applies a Gaussian blur to the view.

func opacity(Double) -> View

Sets the transparency of the view.

func brightness(Double) -> View

Brightens the view by the specified amount.

func contrast(Double) -> View

Sets the contrast and separation between similar colors in this view.

func colorInvert() -> View

Inverts the colors in this view.

func colorMultiply(Color) -> View

Adds a color multiplication effect to this view.

func saturation(Double) -> View

Adjusts the color saturation of this view.

func grayscale(Double) -> View

Adds a grayscale effect to this view.

func hueRotation(Angle) -> View

Applies a hue rotation effect to this view.

func luminanceToAlpha() -> View

Adds a luminance to alpha effect to this view.

Compositing Views

func blendMode(BlendMode) -> View

Sets the blend mode for compositing this view with overlapping views.

enum BlendMode

Modes for compositing a view with overlapping content.

func compositingGroup() -> View

Wraps this view in a compositing group.

func drawingGroup(opaque: Bool, colorMode: ColorRenderingMode) -> View

Composites this view’s contents into an offscreen image before final display.

enum ColorRenderingMode

The working color space for color-compositing operations.

Adding Animations to a View

func animation(Animation?) -> View

Applies the given animation to all animatable values within the view.

func animation<V>(Animation?, value: V) -> View

Applies the given animation to the view when the specified value changes.

func transition(AnyTransition) -> View

Associates a transition with the view.

See Also

Configuring Views

Layout

Tell a view how to arrange itself within a view hierarchy by adjusting its size, position, alignment, padding, and so on.

Accessibility

Make your views accessible to a broad range of users, including people with disabilities.

Styling

Indicate how to style the text, controls, and other content contained in a view.