<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIButton/init(frame:primaryAction:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIButton(im)initWithFrame:primaryAction:"
  },
  "title" : "init(frame:primaryAction:)"
}
-->

# init(frame:primaryAction:)

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

```
convenience init(frame: CGRect, primaryAction: UIAction?)
```

## Parameters

`frame`

The frame rectangle for the view, measured in points.

`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.

## Discussion

---

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)