<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameController",
  "identifier" : "/documentation/GameController/GCVirtualController/setValue(_:forButtonElement:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Game Controller"
    ],
    "preciseIdentifier" : "c:objc(cs)GCVirtualController(im)setValue:forButtonElement:"
  },
  "title" : "setValue(_:forButtonElement:)"
}
-->

# setValue(_:forButtonElement:)

Changes the value of a button element in the virtual controller.

```
func setValue(_ value: CGFloat, forButtonElement element: String)
```

## Parameters

`value`

A value in the range `[-1.0, 1.0]`.

`element`

The name of the button element to update.

## Discussion

Use this method to update the value of a button element in the virtual controller when you set the [`isHidden`](/documentation/GameController/GCVirtualController/Configuration/isHidden) property to <doc://com.apple.documentation/documentation/Swift/true> and present your own virtual controller interface.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)