0% found this document useful (0 votes)
6 views1 page

Scaled Metric

The document describes the creation and use of a ScaledShape in a SwiftUI context, allowing for scaling shapes while retaining their properties. It outlines two main use cases for ScaledShape and provides a simple code example demonstrating its implementation. Additionally, it includes a visual representation of a scaled rectangle within an orange border.

Uploaded by

jon.moses2000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Scaled Metric

The document describes the creation and use of a ScaledShape in a SwiftUI context, allowing for scaling shapes while retaining their properties. It outlines two main use cases for ScaledShape and provides a simple code example demonstrating its implementation. Additionally, it includes a visual representation of a scaled rectangle within an orange border.

Uploaded by

jon.moses2000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Creates the scaled metric with an unscaled value and a text style to

scale relative to.


Creates the scaled metric with an unscaled value using the default
scaling.
The value scaled based on the current environment.
A shape with a scale transform applied to it.

A scaled shape has two use cases:


1. Used directly via its initializer, ``ScaledShape/init(shape:scale:anchor:)``.
2. As the return value of the ``Shape/scale(x:y:anchor:)`` and
``Shape/scale(_:anchor:)``.

Having a scaled shape is helpful because it allows you to scale a shape


and then continue to use its shape properties, instead of turning into ``View``.

A simple example of constructing a ``ScaledShape``:

```
struct ContentView: View {
let scale = CGSize(width: 0.5, height: 0.5)

var body: some View {


ScaledShape(shape: Rectangle(), scale: scale)
.border(Color.orange)
.padding()
}
}
```

![A screenshot displaying an orange rectangular border near the edges of


the screen. Inset within this border is a black filled rectangle that is
scaled down to half the size of its surrounding border by applying a 0.5 scale
in the scaledShape initializer.](scaledshape.png)

You might also like