Instance Method

scaleEffect(_:anchor:)

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

Declaration

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

Parameters

s

The amount to scale the view in the view in both the horizontal and vertical directions.

anchor

The anchor point with a default of center that indicates the starting position for the scale operation.

Discussion

Use scaleEffect(_:anchor:) to apply a horizontally and vertically scaling transform to a view.

Image(systemName: "envelope.badge.fill")
    .resizable()
    .frame(width: 100, height: 100, alignment: .center)
    .foregroundColor(Color.red)
    .scaleEffect(2, anchor: .leading)
    .border(Color.gray)
A screenshot showing a 100x100 pixel red envelope scaled up to 2x the size of its view.

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