Creates and returns a new button of the specified type.
- iOS 2.0+
- tvOS 9.0+
The button type. See
UIButtonfor the possible values.
A newly created button.
This method is a convenience constructor for creating button objects with specific configurations. If you subclass
UIButton, this method does not return an instance of your subclass. If you want to create an instance of a specific subclass, you must alloc/init the button directly.
When creating a custom button—that is a button with the type
UIButton—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.