> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/ios/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/ios/swiftui/shapes/anchor-less-than-t-greater-than.md).

# Anchor\<T>

{% hint style="info" %}

* <mark style="color:purple;">**Anchor\<T>**</mark> is an <mark style="color:red;">**opaque type**</mark> that holds a value of type T, and T can be either <mark style="color:purple;">**CGRect**</mark> or <mark style="color:purple;">**CGPoint**</mark>.&#x20;
* use Anchor<<mark style="color:red;">**CGRect**</mark>> to access the <mark style="color:red;">**bounds**</mark> of a view,&#x20;
* use Anchor<<mark style="color:red;">**CGPoint**</mark>> for other view properties such as **top**, **topLeading**, **topTrailing**, **center**, **trailing**, **bottom**, **bottomLeading**, **bottomTrailing** and **leading**.
  {% endhint %}

{% hint style="info" %}
這個物件其實是給 [GeometryProxy](/ios/swiftui/view/measure/geometryproxy.md) 用的。\
👉  詳見：[Anchor Preferences](/ios/swiftui/data-flow/preferences/anchor-preferences.md)
{% endhint %}

{% tabs %}
{% tab title="📗 參考" %}

* SwiftUI Lab ⟩&#x20;
  * [ ] [Inspecting the View Tree – Part 2: AnchorPreferences](https://swiftui-lab.com/communicating-with-the-view-tree-part-2/)
    {% endtab %}

{% tab title="📘 手冊" %}

* SwiftUI ⟩&#x20;
  * [View Modifiers](https://developer.apple.com/documentation/swiftui/outlinegroup-view-modifiers) ⟩&#x20;
    * [.anchorPreference(key:value:transform:)](https://developer.apple.com/documentation/swiftui/outlinegroup/anchorpreference\(key:value:transform:\))
  * [Drawing and Animation](https://developer.apple.com/documentation/swiftui/drawing-and-animation) ⟩&#x20;
    * [GeometryProxy](https://developer.apple.com/documentation/swiftui/geometryproxy) ⟩&#x20;
      * .[subscript(\_:)](https://developer.apple.com/documentation/swiftui/geometryproxy/subscript\(_:\))
    * [Anchor](https://developer.apple.com/documentation/swiftui/anchor) (<mark style="color:red;">**struct**</mark>)
      * [Anchor.Source](https://developer.apple.com/documentation/swiftui/anchor/source) (<mark style="color:red;">**struct**</mark>)
        {% endtab %}

{% tab title="👥 相關" %}

* [Anchor Preferences](/ios/swiftui/data-flow/preferences/anchor-preferences.md)
* [GeometryProxy](/ios/swiftui/view/measure/geometryproxy.md)
* [GeometryProxy+ext](/ios/swiftui/view/measure/geometryproxy/geometryproxy.md)
* [ GeometryReader](/ios/swiftui/view/measure/geometryreader.md)
  {% endtab %}
  {% endtabs %}
