---
title: "init(frame:primaryAction:)"
framework: uikit
role: symbol
role_heading: Initializer
path: "uikit/uibutton/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.

## Declaration

```swift
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 doc://com.apple.uikit/documentation/UIKit/UIControl/Event/primaryActionTriggered control event and sets the title and image properties to the action’s title and image.

## See Also

### Creating buttons

- [init(frame:)](uikit/uibutton/init(frame:).md)
- [init(coder:)](uikit/uibutton/init(coder:).md)
