<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSButtonCell/setButtonType(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSButtonCell(im)setButtonType:"
  },
  "title" : "setButtonType(_:)"
}
-->

# setButtonType(_:)

Sets how the button highlights while pressed and how it shows its state.

```
func setButtonType(_ type: NSButton.ButtonType)
```

## Parameters

`type`

A constant specifying the type of button. This can be one of the constants defined in [`NSButton.ButtonType`](/documentation/AppKit/NSButton/ButtonType).

## Discussion

The  [`setButtonType(_:)`](/documentation/AppKit/NSButtonCell/setButtonType(_:)) method redisplays the button before returning.

The types available are for the most common button types, which are also accessible in Interface Builder; you can configure different behavior with the [`highlightsBy`](/documentation/AppKit/NSButtonCell/highlightsBy) and [`showsStateBy`](/documentation/AppKit/NSButtonCell/showsStateBy) properties.

Note that there is no `-buttonType` method. The set method sets various button properties that together establish the behavior of the type.

## See Also

[`image`](/documentation/AppKit/NSCell/image)

The image displayed by the cell, if any.

[`alternateImage`](/documentation/AppKit/NSButtonCell/alternateImage)

The image the button displays in its alternate state.



---

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)