# UIAspectRatioConstraint

UIAspectRatioConstraint : `Instance`

## Overview

UI 요소가 화면 크기 변화나 부모 요소 비율에 영향을 받더라도 항상 지정된 가로세로 비율을 유지하도록 강제로 조정해 주는 인스턴스입니다. 예를 들어, 2:1 비율을 지정하면 높이가 변화하더라도 너비는 자동으로 그 두 배가 되며, 1:1을 지정하면 어떤 환경에서도 정사각형 형태를 유지하게 됩니다.

특히 정사각형 이미지처럼 비율이 흐트러지면 품질이 저하되는 UI 요소를 다룰 때 매우 효과적입니다. 또한 다른 UIGridLayout, UIListLayout 등 UI 레이아웃이 요소 크기를 조정하려는 상황에서도, 가로세로 비율 제약이 최우선으로 적용되어 UI 객체의 크기를 결정하게 됩니다.

UIAspectRatioConstraint은 **클라이언트 환경**에서만 제어할 수 있습니다.

## Properties

### AspectRatio

`number`

UI 요소가 어떤 가로세로 비율을 유지해야 하는지를 지정합니다.

예를 들어 2를 입력하면 너비가 높이의 두 배가 되며, 반대로 세로 기준의 비율을 유지하고 싶다면 해당 숫자의 역수를 사용하시면 됩니다.

값은 0보다 커야 정상적으로 적용되며, 잘못된 비율 값은 제약 조건이 올바르게 작동하지 않게 만들 수 있습니다.

#### Code Samples

### AspectType

`Enum.AspectType`

UI 요소가 얼마나 크게 확장될 수 있는지를 제어하는 방식입니다.

FitWithinMaxSize를 선택하면 객체는 실제 크기(AbsoluteSize)를 넘지 않는 선에서 가장 크게 그려지며, ScaleWithParentSize를 선택하면 부모 UI의 크기를 기준으로 가능한 한 크게 조정됩니다.

#### Code Samples

```lua
local UIAspectRatioConstraint = script.Parent

UIAspectRatioConstraint.AspectType = Enum.AspectType.FitWithinMaxSize
```

### DominantAxis

`Enum.DominantAxis`

UI 요소가 부모보다 커지려고 할 때, 어떤 방향(가로 또는 세로)을 기준으로 크기 조정을 진행할지를 결정합니다. 즉, UI 요소가 부모의 제한을 넘지 않도록 할 때, 먼저 어떤 축을 기준 삼아 비율 조정이 이루어질지를 정의하는 역할을 합니다.

#### Code Samples

```lua
local UIAspectRatioConstraint = script.Parent

UIAspectRatioConstraint.DominantAxis = Enum.DominantAxis.Width
```

## Methods

## Events

## See also

{% content-ref url="/pages/K1g0tEWDJhh6a6E4UURk" %}
[GUI](/korean/manual/studio-manual/gui.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.overdare.com/korean/development/api-reference/classes/uiaspectratioconstraint.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
