Title: Theory / Important / CS / Programming / Objective-C / Library / UIKit / Control / Button
On every note of this deck, unless a note says otherwise:
Page: https://developer.apple.com/documentation/uikit/uibutton?language=objc
Context: iOS UI
Language: Objective-C
Page: https://developer.apple.com/documentation/uikit/uibutton?language=objc
Language: Objective-C
Context: iOS UI

Constant: UIControlEventPrimaryActionTriggered
Meaning: A semantic action triggered by buttons.
Page: https://developer.apple.com/documentation/uikit/uicontrol/1618245-state?language=objc
Language: Objective-C
Typ: UIcontrolEvents

Typ: UIButton
Meaning: A control that executes your custom code in response to user interactions.
Page: https://developer.apple.com/documentation/uikit/uibutton?language=objc
Language: Objective-C

Question: How to create a UIButton
Answer: Set the type of the button at creation time
Page: https://developer.apple.com/documentation/uikit/uibutton?language=objc
Context: iOS UI
Answer2: Supply a title string or image, size the button appropiately for your content
Answer3: Connect one or more action methods to the button.
Answer4: Set up Auto Layout rules to govern the size and position of the button in your interface.
Answer5: Provide accessibility information and localized strings.

Question: What is the default state of a button
Answer: Enabled, no user interaction
Page: https://developer.apple.com/documentation/uikit/uibutton?language=objc
Context: iOS UI

Variable: button.type
Meaning: the buttonType of the button
Variables: UIButton button

Variable: button.stateConfig
Meaning: The state selector
Variables: UIButton button

Variable: button.titleLabel
Meaning: A view that displays the value of the currentTitle property for a button.
Variables: UIButton button

Variable: button.drawing
Meaning: The drawing behavior of the button.
Variables: UIButton button

Variable: button.edge
Meaning: The edge insets to configure.
Variables: UIButton button

Variable: button.inset
Meaning: The inset values.
Variables: UIButton button

Variable: button.configuration
Meaning: The configuration for the button’s appearance.
Typ: UIButtonConfiguration
Variables: UIButton button

Variable: button.automaticallyUpdatesConfiguration
Meaning: whether the button configuration changes when button’s state changes.
Variables: UIButton button

Variable: button.configurationUpdateHandler
Meaning: A closure that executes when the button state changes.
Typ: UIButtonConfigurationUpdateHandler
Variables: UIButton button

Variable: button.tint
Meaning: The tint color to apply to the button title and image.
Typ: UIColor
Variables: UIButton button

Variable: button.role
Meaning: the role of the button
Typ: UIButtonRole
Variables: UIButton button

Variable: button.behavioralStyle
Meaning: The style that determines how the button behaves.
Typ: UIBehavioralStyle
Variables: UIButton button

Variable: button.preferredBehavioralStyle
Meaning: The preferred behavioral style.
Typ: UIBehavioralStyle
Variables: UIButton button

Variable: button.buttonType
Meaning: The button type.
Typ: UIButtonType
Variables: UIButton button

Variable: button.currentTitle
Meaning: The current title that is displayed on the button.
Variables: UIButton button

Variable: button.currentAttributedTitle
Meaning: The current styled title that is displayed on the button.
Typ: NSAttributedString
Variables: UIButton button

Variable: button.currentTitleColor
Meaning: The color used to display the title.
Variables: UIButton button

Variable: button.currentTitleshadowColor
Meaning: The color of the title’s shadow.
Variables: UIButton button

Variable: button.currentImage
Meaning: The current image displayed on the button.
Variables: UIButton button

Variable: button.currentBackgroundImage
Meaning: The current background image displayed on the button.
Variables: UIButton button

Variable: button.currentPreferredSymbolConfiguration
Meaning: The current symbol size, style, and weight.
Typ: UIImageSymbol
Variables: UIButton button

Variable: button.imageView
Meaning: The button's image view. Read only, but its property can be modified
Typ: UIImageView
Variables: UIButton button

Variable: button.subtitleLabel
Meaning: The label that displays the text of the subtitle.
Variables: UIButton button

Variable: button.pointerInteractionEnabled
Meaning: Whether pointer interaction is enabled
Variables: UIButton button

Variable: button.hovered
Meaning: whether a pointer effect is active.
Variables: UIButton button

Variable: button.pointerStyleProvider
Meaning: A block that returns the pointer style to use when the pointer hovers over the button.
Variables: UIButton button

Variable: button.menu
Meaning: A menu that the button displays.
Variables: UIButton button
Initialization: nil

Variable: button.held
Meaning: whether the button menu is visible.
Variables: UIButton button

Variable: button.changesSelectionAsPrimaryAction
Meaning: whether the button tracks a selection, either through a menu or a toggle.
Variables: UIButton button

Instruction: [button
  initWithFrame:frame
]
Effect: Creates a new button with the specified frame.
Variables: UIButton button

Instruction: [button
  initWithFrame:frame
  primaryAction:primaryAction
]
Effect: 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.
Variables: UIButton button

Instruction: [button
  initWithCoder:coder
]
Effect: a new button with data in an unarchiver.
Variables: UIButton button

Instruction: [button
  setNeedsUpdateConfiguration
]
Effect: Requests the system update the button configuration.
Variables: UIButton button

Instruction: [button
  updateConfiguration
]
Effect: Updates button configuration in response to button state change.
Variables: UIButton button

Instruction: [button
  titleForState:state
]
Returns: the title associated with the specified state.
Variables: UIButton button

Instruction: [button
  setTitle:title
  forState:state
]
Effect: Sets the title to use for the specified state.
Returns: the title associated with the specified state.
Variables: UIButton button

Instruction: [button
  attributedTitleForState:state
]
Returns: the styled title associated with the specified state.
Variables: UIButton button

Instruction: [button
  setAttributedTitle:title
  forState:state
]
Effect: Sets the styled title to use for the specified state.
Variables: UIButton button

Instruction: [button
  titleColorForState:state
]
Returns: the title color used for a state.
Variables: UIButton button

Instruction: [button
  setTitleColor:color
  forState:state
]
Effect: Sets the color of the title to use for the specified state.
Variables: UIButton button

Instruction: [button
  titleShadowColorForState:state
]
Returns: the shadow color of the title used for a state.
Variables: UIButton button

Instruction: [button
  setTitleShadowColor:color
  forState:state
]
Effect: Sets the color of the title shadow to use for the specified state.
Variables: UIButton button

Instruction: [button
  backgroundImageForState:state
]
Returns: the background image used for a button state.
Variables: UIButton button

Instruction: [button
  imageForState:state
]
Returns: the image used for a button state.
Variables: UIButton button

Instruction: [button
  setBackgroundImage:image
  forState:state
]
Effect: Sets the background image to use for the specified button state.
Variables: UIButton button

Instruction: [button
  setImage:image
  forState:state
]
Effect: Sets the image to use for the specified state.
Variables: UIButton button

Instruction: [button
  preferredSymbolConfigurationForImageInState:state
]
Returns: the preferred symbol configuration for a button state.
Variables: UIButton button

Instruction: [button
  setPreferredSymbolConfigurationForImageInState:state
  forImageInState:state
]
Effect: Setsthe preferred symbol configuration for a button state.
Variables: UIButton button

Instruction: [SomeButtonType
  buttonWithConfiguration:configuration
  primaryAction:primaryAction
]
Returns: A new button  of SomeButtonType with the specified configuration and registers the primary action event."
Variables: UIButton button

Instruction: [SomeButtonType
  systemButtonWithPrimaryAction:primaryAction
]
Returns: A button of SomeButtonType doing primaryAction
Variables: UIButton button

Instruction: [SomeButtonType
  systemButtonWithImage:image
  target:target
  action:action
]
Returns: a system type button of someButtonType with specified image, target, and action.
Variables: UIButton button

Instruction: [SomeButtonType
  buttonWithType:buttonType
  primaryAction:primaryAction
]
Returns: ?
Variables: UIButton button

Instruction: [SomeButtonType
  buttonWithType:buttonType
]
Returns: a new button of the specified type.

Typ: UIButtonType
TypMeaning: Specifies the style of a button.
Page: https://developer.apple.com/documentation/uikit/uibutton?language=objc
Language: Objective-C
Context: iOS UI
Value: UIButtonTypeCustom
No button style.
Value2: UIButtonTypeSystem
A system style button, such as those shown in navigation bars and toolbars.
Value3: UIButtonTypeDetailDisclosure
A detail disclosure button.
Value4: UIButtonTypeInfoLight
An information button that has a light background.
Value5: UIButtonTypeInfoDark
An information button that has a dark background.
Value6: UIButtonTypeContactAdd
A contact add button.
Value7: UIButtonTypePlain
A standard system button without a blurred background view.
Value8: UIButtonTypeClose
A close button to dismiss panels and views.
Value9: UIButtonTypeRoundedRect
A rounded-rectangle style button.

Typ: UIButtonConfiguration
Meaning: A configuration that specifies the appearance and behavior of a button and its contents.
Page: https://developer.apple.com/documentation/uikit/uibutton?language=objc
Language: Objective-C
Context: iOS UI

Variable: buttonConfiguration.title
Meaning: The text of the title label the button displays.
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.subtitle
Meaning: The text the subtitle label of the button displays.
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.attributedTitle
Meaning: The text and style attributes for the button’s title label.
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.attributedSubtitle
Meaning: The text and style attributes for the button’s subtitle label.
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.titleTextAttributesTransformer
Meaning: A block to update the attributed title when the button state changes.
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.subtitleTextAttributesTransformer
Meaning: A block to update the attributed subtitle when the button state changes.
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.titlePadding
Meaning: The distance between the title and subtitle labels.
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.titleAlignment
Meaning: The text alignment the button uses to lay out the title and subtitle.
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.image
Meaning: The foreground image the button displays.
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.imagePadding
Meaning: The distance between the button’s image and text.
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.showsActivityIndicator
Meaning: whether the button displays an activity indicator instead of an image.
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.imagePlacement
Meaning: The edge against which the button places the image.
Typ: NSDirectionalRectEdge
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.imageColorTransformer
Meaning: A block that transforms the image color when the button state changes.
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.preferredSymbolConfigurationForImage
Meaning: A requested configuration object for the button symbol image.
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.buttonSize
Meaning: A size that requests a preferred size for the button.
Typ: UIButtonConfigurationSize
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.contentInsets
Meaning: The distance from the button’s content area to its bounds.
Typ: NSDirectionalEdgeInsets
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.base(Back|Fore)groundColor
Meaning: The untransformed color for (Back|Fore)ground views.
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.background
Meaning: The configuration to customize the button background.
Typ: UIBackgroundConfiguration
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.cornerStyle
Meaning: The button style that controls the display behavior of the background corner radius.
Typ: UIButtonConfigurationCornerStyle
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.macIdiomStyle
Meaning: The style to use when this button appears in macOS.
Typ: UIButtonConfigurationMacIdiomStyle
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.activityIndicatorColorTransformer
Meaning: ?
Typ: UIConfigurationColorTransformer
Variables: UIButtonConfiguratio buttonConfiguration

Variable: buttonConfiguration.automaticallyUpdateForSelection
Meaning: ?
Variables: UIButtonConfiguratio buttonConfiguration

Instruction: [buttonConfiguration
  setDefaultContentInsets
]
Effect: Set content insets to default value
Variables: UIButtonConfiguratio buttonConfiguration

Instruction: [buttonConfiguration
  updatedConfigurationForButton:button
]
Returns: a copy of the configuration, updated for the given button.
Variables: UIButtonConfiguratio buttonConfiguration

Instruction: [UIButtonConfiguration
  borderlessButtonConfiguration
]
Effect: ?
Variables: UIButtonConfiguratio buttonConfiguration

Instruction: [UIButtonConfiguration
  borderedTintedButtonConfiguration
]
Effect: ?
Variables: UIButtonConfiguratio buttonConfiguration

Instruction: [UIButtonConfiguration
  borderedProminentButtonConfiguration
]
Effect: ?
Variables: UIButtonConfiguratio buttonConfiguration

Instruction: [UIButtonConfiguration
  borderedButtonConfiguration
]
Effect: ?
Variables: UIButtonConfiguratio buttonConfiguration

Instruction: [UIButtonConfiguration
  tintedButtonConfiguration
]
Returns: a configuration for a button with a tinted background color.
Variables: UIButtonConfiguratio buttonConfiguration

Instruction: [UIButtonConfiguration
  grayButtonConfiguration
]
Variables: a configuration for a button with a gray background.

Instruction: [UIButtonConfiguration
  filledButtonConfiguration
]
Returns: a configuration for a button with a background filled with the button’s tint color.
Variables: a configuration for a button with a gray background.

Instruction: [UIButtonConfiguration
  plainButtonConfiguration
]
Returns: a configuration for a button with a transparent background.
Variables: a configuration for a button with a gray background.

Typ: UIButtonConfigurationTitleAlignment
TypMeaning: Specifies how to align a button’s title and subtitle.
Page: https://developer.apple.com/documentation/uikit/uibutton?language=objc
Language: Objective-C
Value: UIButtonConfigurationTitleAlignmentAutomatic
Aligns the title and subtitle based on other elements in the button configuration, like an image or activity indicator.
Value2: UIButtonConfigurationTitleAlignmentCenter
Aligns the title and subtitle on their horizontal centers.
Value3: UIButtonConfigurationTitleAlignment(Leading|Trailing)
Aligns the title and subtitle on their leading|trailing edges.

Typ: UIConfigurationTextAttributesTransformer
Meaning: Defines a text transformation that can affect the visual appearance of a string.
Page: https://developer.apple.com/documentation/uikit/uibutton?language=objc
Language: Objective-C

Typ: UIButtonConfigurationSize
TypMeaning: A predefined size for button elements.
Page: https://developer.apple.com/documentation/uikit/uibutton?language=objc
Language: Objective-C
Value: UIButtonConfigurationSizeMini
Displays button elements at the smallest size.
Value2: UIButtonConfigurationSizeSmall
Displays button elements at a small size.
Value3: UIButtonConfigurationSizeMedium
Displays button elements at a standard size.
Value4: UIButtonConfigurationSizeLarge
Displays button elements at a large size.

Typ: UIButtonConfigurationCornerStyle
TypMeaning: Settings that determine the appearance of the background corner radius.
Page: https://developer.apple.com/documentation/uikit/uibutton?language=objc
Language: Objective-C
Value: UIButtonConfigurationCornerStyleDynamic
A style that adjusts the background corner radius for dynamic type.
Value2: UIButtonConfigurationCornerStyleFixed
A style that uses the background corner radius without modification.
Value3: UIButtonConfigurationCornerStyleCapsule
A style that ignores the background corner radius and uses a corner radius that generates a capsule.
Value4: UIButtonConfigurationCornerStyleLarge
A style that ignores the background corner radius and uses a large system-defined corner radius.
Value5: UIButtonConfigurationCornerStyleMedium
A style that ignores the background corner radius and uses a medium system-defined corner radius.
Value6: UIButtonConfigurationCornerStyleSmall
A style that ignores the background corner radius and uses a small system-defined corner radius.

Typ: UIButtonConfigurationMacIdiomStyle
TypMeaning: The button style your app uses when running in macOS.
Page: https://developer.apple.com/documentation/uikit/uibutton?language=objc
Language: Objective-C
Value: UIButtonConfigurationMacIdiomStyleAutomatic
The button has a style that matches other content in the button configuration.
Value2: UIButtonConfigurationMacIdiomStyleBordered
The button has a bordered style.
Value3: UIButtonConfigurationMacIdiomStyleBorderless
The button has a borderless style.
Value4: UIButtonConfigurationMacIdiomStyleBorderlessTinted
The button has a tinted, bordlerless style.

Typ: UIButtonConfigurationUpdateHandler
Meaning: A closure to update the configuration of a button.
Language: Objective-C

Typ: UIButtonRole
TypMeaning: describe the role of the button.
Page: https://developer.apple.com/documentation/uikit/uibuttonrole?language=objc
Language: Objective-C
Value: UIButtonRoleNormal
A button role for a default button style.
Value2: UIButtonRolePrimary
A button role that responds to a primary key press.
Value3: UIButtonRoleCancel
A button role that responds to a cancel action.
Value4: UIButtonRoleDestructive
A button role with a red background color.

Typ: UIBehavioralStyle
TypMeaning: how a control behaves in apps built with Mac Catalyst.
Page: https://developer.apple.com/documentation/uikit/uibuttonrole?language=objc
Language: Objective-C
Value: UIBehavioralStyleAutomatic
A style the system chooses based on the app’s targeted platform.
Value2: UIBehavioralStylePad
A style that indicates that a control appears and behaves as it does in iPadOS.
Value3: UIBehavioralStyleMac
A style that indicates that a control appears and behaves as it does in macOS.

Typ: UIButtonPointerStyleProvider
Meaning: a block that returns a pointer style to apply to a button or nil
Page: https://developer.apple.com/documentation/uikit/uibuttonpointerstyleprovider?language=objc
Language: Objective-C
Implementation: typedef UIPointerStyle * _Nullable (^UIButtonPointerStyleProvider)(UIButton *button, UIPointerEffect *proposedEffect, UIPointerShape *proposedShape);