Instance Method

scaleEffect(_:anchor:)

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

Declaration

func scaleEffect(_ scale: CGSize, anchor: UnitPoint = .center) -> some View

Parameters

scale

A CGSize that represents the horizontal and vertical amount to scale the view.

anchor

The point with a default of center that defines the location within the view from which to apply the transformation.

Discussion

Use scaleEffect(_:anchor:) to apply a scaling transform a view to a specific size, specified by a scale.

Image(systemName: "envelope.badge.fill")
    .resizable()
    .frame(width: 100, height: 100, alignment: .center)
    .foregroundColor(Color.red)
    .scaleEffect(CGSize(x: 0.9, y: 1.3), anchor: .leading)
    .border(Color.gray)
A screenshot showing a red envelope scaled to a size of 90x130 pixels.

See Also

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(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.