Instance Method

scaleEffect(x:y:anchor:)

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

Declaration

func scaleEffect(x: CGFloat = 0.0, y: CGFloat = 0.0, anchor: UnitPoint = .center) -> some View

Parameters

x

An amount that represents the horizontal amount to scale the view.

y

An amount that represents the vertical amount to scale the view.

anchor

The anchor point that indicates the starting position for the scale operation.

Discussion

Use scaleEffect(x:y:anchor:) to apply a scaling transform to a view by a specific horizontal and vertical amount.

Image(systemName: "envelope.badge.fill")
    .resizable()
    .frame(width: 100, height: 100, alignment: .center)
    .foregroundColor(Color.red)
    .scaleEffect(x: 0.5, y: 0.5, anchor: .bottomTrailing)
    .border(Color.gray)
A screenshot showing a 100x100 pixel red envelope scaled down 50% in both the x and y axes.

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(CGSize, anchor: UnitPoint) -> View

Scales this view’s rendered output by the given vertical and horizontal size 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.