<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: -",
    "tvOS: 14.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIButton/init(type:primaryAction:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "s:So8UIButtonC5UIKitE4type13primaryActionABSo0A4TypeV_So8UIActionCSgtcfc"
  },
  "title" : "init(type:primaryAction:)"
}
-->

# init(type:primaryAction:)

Creates a new button with the specified type, registers the primary action event, and sets the title and image to the action’s title and image.

```
@MainActor @preconcurrency convenience init(type buttonType: UIButton.ButtonType = .system, primaryAction: UIAction?)
```

## Parameters

`buttonType`

The type of button.

`primaryAction`

The action to perform when the button is selected. The button registers this action for the [`primaryActionTriggered`](/documentation/UIKit/UIControl/Event/primaryActionTriggered) control event and sets the title and image properties to the action’s title and image.

---

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)