init(type:)
Creates and returns a new button of the specified type.
Declaration
convenience init(type buttonType: UIButton.ButtonType)Parameters
- buttonType:
The button type. See Buttontype Swift.enum for the possible values.
Return Value
A newly created button.
Discussion
This method is a convenience constructor for creating button objects with specific configurations.
When creating a custom button — a button with the type UIButton.ButtonType.custom — the frame of the button is set to (0, 0, 0, 0) initially. Before adding the button to your interface, you should update the frame to a more appropriate value.