objc2_ui_kit/generated/
UIButton.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-quartz-core")]
10#[cfg(not(target_os = "watchos"))]
11use objc2_quartz_core::*;
12
13use crate::*;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uibuttontype?language=objc)
16// NS_ENUM
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct UIButtonType(pub NSInteger);
20impl UIButtonType {
21    #[doc(alias = "UIButtonTypeCustom")]
22    pub const Custom: Self = Self(0);
23    #[doc(alias = "UIButtonTypeSystem")]
24    pub const System: Self = Self(1);
25    #[doc(alias = "UIButtonTypeDetailDisclosure")]
26    pub const DetailDisclosure: Self = Self(2);
27    #[doc(alias = "UIButtonTypeInfoLight")]
28    pub const InfoLight: Self = Self(3);
29    #[doc(alias = "UIButtonTypeInfoDark")]
30    pub const InfoDark: Self = Self(4);
31    #[doc(alias = "UIButtonTypeContactAdd")]
32    pub const ContactAdd: Self = Self(5);
33    #[doc(alias = "UIButtonTypePlain")]
34    pub const Plain: Self = Self(6);
35    #[doc(alias = "UIButtonTypeClose")]
36    pub const Close: Self = Self(7);
37    #[doc(alias = "UIButtonTypeRoundedRect")]
38    pub const RoundedRect: Self = Self(UIButtonType::System.0);
39}
40
41unsafe impl Encode for UIButtonType {
42    const ENCODING: Encoding = NSInteger::ENCODING;
43}
44
45unsafe impl RefEncode for UIButtonType {
46    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
47}
48
49/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uibuttonrole?language=objc)
50// NS_ENUM
51#[repr(transparent)]
52#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
53pub struct UIButtonRole(pub NSInteger);
54impl UIButtonRole {
55    #[doc(alias = "UIButtonRoleNormal")]
56    pub const Normal: Self = Self(0);
57    #[doc(alias = "UIButtonRolePrimary")]
58    pub const Primary: Self = Self(1);
59    #[doc(alias = "UIButtonRoleCancel")]
60    pub const Cancel: Self = Self(2);
61    #[doc(alias = "UIButtonRoleDestructive")]
62    pub const Destructive: Self = Self(3);
63}
64
65unsafe impl Encode for UIButtonRole {
66    const ENCODING: Encoding = NSInteger::ENCODING;
67}
68
69unsafe impl RefEncode for UIButtonRole {
70    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
71}
72
73/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uibuttonpointerstyleprovider?language=objc)
74#[cfg(all(
75    feature = "UIControl",
76    feature = "UIHoverStyle",
77    feature = "UIPointerStyle",
78    feature = "UIResponder",
79    feature = "UIView",
80    feature = "block2"
81))]
82pub type UIButtonPointerStyleProvider = *mut block2::Block<
83    dyn Fn(
84        NonNull<UIButton>,
85        NonNull<UIPointerEffect>,
86        NonNull<UIPointerShape>,
87    ) -> *mut UIPointerStyle,
88>;
89
90/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uibuttonconfigurationupdatehandler?language=objc)
91#[cfg(all(
92    feature = "UIControl",
93    feature = "UIResponder",
94    feature = "UIView",
95    feature = "block2"
96))]
97pub type UIButtonConfigurationUpdateHandler = *mut block2::Block<dyn Fn(NonNull<UIButton>)>;
98
99extern_class!(
100    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uibutton?language=objc)
101    #[unsafe(super(UIControl, UIView, UIResponder, NSObject))]
102    #[thread_kind = MainThreadOnly]
103    #[derive(Debug, PartialEq, Eq, Hash)]
104    #[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
105    pub struct UIButton;
106);
107
108#[cfg(all(
109    feature = "UIControl",
110    feature = "UIResponder",
111    feature = "UIView",
112    feature = "objc2-quartz-core"
113))]
114#[cfg(not(target_os = "watchos"))]
115unsafe impl CALayerDelegate for UIButton {}
116
117#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
118unsafe impl NSCoding for UIButton {}
119
120#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
121unsafe impl NSObjectProtocol for UIButton {}
122
123#[cfg(all(
124    feature = "UIAppearance",
125    feature = "UIControl",
126    feature = "UIResponder",
127    feature = "UIView"
128))]
129unsafe impl UIAppearance for UIButton {}
130
131#[cfg(all(
132    feature = "UIAppearance",
133    feature = "UIControl",
134    feature = "UIResponder",
135    feature = "UIView"
136))]
137unsafe impl UIAppearanceContainer for UIButton {}
138
139#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
140unsafe impl UICoordinateSpace for UIButton {}
141
142#[cfg(all(
143    feature = "UIControl",
144    feature = "UIDynamicBehavior",
145    feature = "UIResponder",
146    feature = "UIView"
147))]
148unsafe impl UIDynamicItem for UIButton {}
149
150#[cfg(all(
151    feature = "UIControl",
152    feature = "UIFocus",
153    feature = "UIResponder",
154    feature = "UIView"
155))]
156unsafe impl UIFocusEnvironment for UIButton {}
157
158#[cfg(all(
159    feature = "UIControl",
160    feature = "UIFocus",
161    feature = "UIResponder",
162    feature = "UIView"
163))]
164unsafe impl UIFocusItem for UIButton {}
165
166#[cfg(all(
167    feature = "UIControl",
168    feature = "UIFocus",
169    feature = "UIResponder",
170    feature = "UIView"
171))]
172unsafe impl UIFocusItemContainer for UIButton {}
173
174#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
175unsafe impl UIResponderStandardEditActions for UIButton {}
176
177#[cfg(all(
178    feature = "UIControl",
179    feature = "UIResponder",
180    feature = "UITraitCollection",
181    feature = "UIView"
182))]
183unsafe impl UITraitEnvironment for UIButton {}
184
185#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
186impl UIButton {
187    extern_methods!(
188        #[cfg(feature = "objc2-core-foundation")]
189        #[unsafe(method(initWithFrame:))]
190        #[unsafe(method_family = init)]
191        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
192
193        #[unsafe(method(initWithCoder:))]
194        #[unsafe(method_family = init)]
195        pub unsafe fn initWithCoder(
196            this: Allocated<Self>,
197            coder: &NSCoder,
198        ) -> Option<Retained<Self>>;
199
200        #[cfg(all(
201            feature = "UIAction",
202            feature = "UIMenuElement",
203            feature = "objc2-core-foundation"
204        ))]
205        /// Initializes a custom button, registers primaryAction for the UIControlEventPrimaryActionTriggered control event, and uses primaryAction's title
206        /// &
207        /// image as the button's title
208        /// &
209        /// image.
210        #[unsafe(method(initWithFrame:primaryAction:))]
211        #[unsafe(method_family = init)]
212        pub unsafe fn initWithFrame_primaryAction(
213            this: Allocated<Self>,
214            frame: CGRect,
215            primary_action: Option<&UIAction>,
216        ) -> Retained<Self>;
217
218        #[unsafe(method(buttonWithType:))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn buttonWithType(
221            button_type: UIButtonType,
222            mtm: MainThreadMarker,
223        ) -> Retained<Self>;
224
225        #[cfg(feature = "UIImage")]
226        #[unsafe(method(systemButtonWithImage:target:action:))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn systemButtonWithImage_target_action(
229            image: &UIImage,
230            target: Option<&AnyObject>,
231            action: Option<Sel>,
232            mtm: MainThreadMarker,
233        ) -> Retained<Self>;
234
235        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
236        /// Creates a system button, registers primaryAction for the UIControlEventPrimaryActionTriggered control event, and uses primaryAction's title
237        /// &
238        /// image as the button's title
239        /// &
240        /// image.
241        #[unsafe(method(systemButtonWithPrimaryAction:))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn systemButtonWithPrimaryAction(
244            primary_action: Option<&UIAction>,
245            mtm: MainThreadMarker,
246        ) -> Retained<Self>;
247
248        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
249        /// Creates a button of the given type, registers primaryAction for the UIControlEventPrimaryActionTriggered control event, and if appropriate uses primaryAction's title
250        /// &
251        /// image as the button's title
252        /// &
253        /// image.
254        #[unsafe(method(buttonWithType:primaryAction:))]
255        #[unsafe(method_family = none)]
256        pub unsafe fn buttonWithType_primaryAction(
257            button_type: UIButtonType,
258            primary_action: Option<&UIAction>,
259            mtm: MainThreadMarker,
260        ) -> Retained<Self>;
261
262        #[cfg(all(
263            feature = "UIAction",
264            feature = "UIButtonConfiguration",
265            feature = "UIMenuElement"
266        ))]
267        /// Construct a new UIButton. `configuration` will be installed on the created button, and `primaryAction` added to handle the .primaryActionTriggered control event. If `primaryAction` has a title or image, they will be copied to `configuration`
268        #[unsafe(method(buttonWithConfiguration:primaryAction:))]
269        #[unsafe(method_family = none)]
270        pub unsafe fn buttonWithConfiguration_primaryAction(
271            configuration: &UIButtonConfiguration,
272            primary_action: Option<&UIAction>,
273        ) -> Retained<Self>;
274
275        #[cfg(feature = "UIButtonConfiguration")]
276        /// Setting a non-nil value for `configuration` will opt into configuration-based behavior on UIButton, update the button in a platform specific manner, and enable/disable some API.
277        #[unsafe(method(configuration))]
278        #[unsafe(method_family = none)]
279        pub unsafe fn configuration(&self) -> Option<Retained<UIButtonConfiguration>>;
280
281        #[cfg(feature = "UIButtonConfiguration")]
282        /// Setter for [`configuration`][Self::configuration].
283        #[unsafe(method(setConfiguration:))]
284        #[unsafe(method_family = none)]
285        pub unsafe fn setConfiguration(&self, configuration: Option<&UIButtonConfiguration>);
286
287        /// Requests the view update its configuration for its current state. This method is called automatically when the button's state may have changed, as well as in other circumstances where an update may be required. Multiple requests may be coalesced into a single update at the appropriate time.
288        #[unsafe(method(setNeedsUpdateConfiguration))]
289        #[unsafe(method_family = none)]
290        pub unsafe fn setNeedsUpdateConfiguration(&self);
291
292        /// Subclasses should override this method and update the button's `configuration`. This method should not be called directly, use `setNeedsUpdateConfiguration` to request an update.
293        #[unsafe(method(updateConfiguration))]
294        #[unsafe(method_family = none)]
295        pub unsafe fn updateConfiguration(&self);
296
297        #[cfg(feature = "block2")]
298        /// Block-based equivalent to overriding -updateConfiguration in a subclass. Setting this handler will force the button into configuration-based behavior (see the `configuration` property). This block is called after `-updateConfiguration`
299        #[unsafe(method(configurationUpdateHandler))]
300        #[unsafe(method_family = none)]
301        pub unsafe fn configurationUpdateHandler(&self) -> UIButtonConfigurationUpdateHandler;
302
303        #[cfg(feature = "block2")]
304        /// Setter for [`configurationUpdateHandler`][Self::configurationUpdateHandler].
305        #[unsafe(method(setConfigurationUpdateHandler:))]
306        #[unsafe(method_family = none)]
307        pub unsafe fn setConfigurationUpdateHandler(
308            &self,
309            configuration_update_handler: UIButtonConfigurationUpdateHandler,
310        );
311
312        /// When YES, the button will automatically call -updatedConfigurationForButton: on its `configuration ` when the button's state changes, and apply the updated configuration to the button. The default value is YES.
313        #[unsafe(method(automaticallyUpdatesConfiguration))]
314        #[unsafe(method_family = none)]
315        pub unsafe fn automaticallyUpdatesConfiguration(&self) -> bool;
316
317        /// Setter for [`automaticallyUpdatesConfiguration`][Self::automaticallyUpdatesConfiguration].
318        #[unsafe(method(setAutomaticallyUpdatesConfiguration:))]
319        #[unsafe(method_family = none)]
320        pub unsafe fn setAutomaticallyUpdatesConfiguration(
321            &self,
322            automatically_updates_configuration: bool,
323        );
324
325        #[cfg(feature = "UIColor")]
326        #[unsafe(method(tintColor))]
327        #[unsafe(method_family = none)]
328        pub unsafe fn tintColor(&self) -> Option<Retained<UIColor>>;
329
330        #[cfg(feature = "UIColor")]
331        /// Setter for [`tintColor`][Self::tintColor].
332        #[unsafe(method(setTintColor:))]
333        #[unsafe(method_family = none)]
334        pub unsafe fn setTintColor(&self, tint_color: Option<&UIColor>);
335
336        #[unsafe(method(buttonType))]
337        #[unsafe(method_family = none)]
338        pub unsafe fn buttonType(&self) -> UIButtonType;
339
340        /// If pointer effects are enabled for the button, this will return true when an effect is active.
341        #[unsafe(method(isHovered))]
342        #[unsafe(method_family = none)]
343        pub unsafe fn isHovered(&self) -> bool;
344
345        /// Returns true while the button is presenting a menu.
346        #[unsafe(method(isHeld))]
347        #[unsafe(method_family = none)]
348        pub unsafe fn isHeld(&self) -> bool;
349
350        #[unsafe(method(role))]
351        #[unsafe(method_family = none)]
352        pub unsafe fn role(&self) -> UIButtonRole;
353
354        /// Setter for [`role`][Self::role].
355        #[unsafe(method(setRole:))]
356        #[unsafe(method_family = none)]
357        pub unsafe fn setRole(&self, role: UIButtonRole);
358
359        /// Enables this button's built-in pointer interaction.
360        #[unsafe(method(isPointerInteractionEnabled))]
361        #[unsafe(method_family = none)]
362        pub unsafe fn isPointerInteractionEnabled(&self) -> bool;
363
364        /// Setter for [`isPointerInteractionEnabled`][Self::isPointerInteractionEnabled].
365        #[unsafe(method(setPointerInteractionEnabled:))]
366        #[unsafe(method_family = none)]
367        pub unsafe fn setPointerInteractionEnabled(&self, pointer_interaction_enabled: bool);
368
369        #[cfg(all(
370            feature = "UIHoverStyle",
371            feature = "UIPointerStyle",
372            feature = "block2"
373        ))]
374        /// Called when the system pointer hovers over this button if its pointer interaction is enabled. The
375        /// system calls this block with a proposed UIPointerEffect and UIPointerShape. You may use them to construct
376        /// a customized version of the system provided style or return an entirely custom one.
377        /// Setting this property automatically enables the button's pointer interaction and sets
378        /// `pointerInteractionEnabled`to true.
379        #[unsafe(method(pointerStyleProvider))]
380        #[unsafe(method_family = none)]
381        pub unsafe fn pointerStyleProvider(&self) -> UIButtonPointerStyleProvider;
382
383        #[cfg(all(
384            feature = "UIHoverStyle",
385            feature = "UIPointerStyle",
386            feature = "block2"
387        ))]
388        /// Setter for [`pointerStyleProvider`][Self::pointerStyleProvider].
389        #[unsafe(method(setPointerStyleProvider:))]
390        #[unsafe(method_family = none)]
391        pub unsafe fn setPointerStyleProvider(
392            &self,
393            pointer_style_provider: UIButtonPointerStyleProvider,
394        );
395
396        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
397        /// An optional menu for the button to display. The button will automatically enable or disable its contextMenuInteraction when a non-nil or nil menu is set. Defaults to nil.
398        #[unsafe(method(menu))]
399        #[unsafe(method_family = none)]
400        pub unsafe fn menu(&self) -> Option<Retained<UIMenu>>;
401
402        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
403        /// Setter for [`menu`][Self::menu].
404        #[unsafe(method(setMenu:))]
405        #[unsafe(method_family = none)]
406        pub unsafe fn setMenu(&self, menu: Option<&UIMenu>);
407
408        #[cfg(feature = "UIContextMenuConfiguration")]
409        /// Preferred menu element ordering strategy for menus displayed by this button.
410        #[unsafe(method(preferredMenuElementOrder))]
411        #[unsafe(method_family = none)]
412        pub unsafe fn preferredMenuElementOrder(&self) -> UIContextMenuConfigurationElementOrder;
413
414        #[cfg(feature = "UIContextMenuConfiguration")]
415        /// Setter for [`preferredMenuElementOrder`][Self::preferredMenuElementOrder].
416        #[unsafe(method(setPreferredMenuElementOrder:))]
417        #[unsafe(method_family = none)]
418        pub unsafe fn setPreferredMenuElementOrder(
419            &self,
420            preferred_menu_element_order: UIContextMenuConfigurationElementOrder,
421        );
422
423        /// Indicates if the button changes selection as its primary action.
424        /// This shows the menu as options for selection if a menu is populated and showsMenuAsPrimaryAction is enabled.
425        /// If no menu is provided or it is not the primary action, UIControlStateSelected is toggled on and off for the primary action.
426        #[unsafe(method(changesSelectionAsPrimaryAction))]
427        #[unsafe(method_family = none)]
428        pub unsafe fn changesSelectionAsPrimaryAction(&self) -> bool;
429
430        /// Setter for [`changesSelectionAsPrimaryAction`][Self::changesSelectionAsPrimaryAction].
431        #[unsafe(method(setChangesSelectionAsPrimaryAction:))]
432        #[unsafe(method_family = none)]
433        pub unsafe fn setChangesSelectionAsPrimaryAction(
434            &self,
435            changes_selection_as_primary_action: bool,
436        );
437
438        #[unsafe(method(setTitle:forState:))]
439        #[unsafe(method_family = none)]
440        pub unsafe fn setTitle_forState(&self, title: Option<&NSString>, state: UIControlState);
441
442        #[cfg(feature = "UIColor")]
443        #[unsafe(method(setTitleColor:forState:))]
444        #[unsafe(method_family = none)]
445        pub unsafe fn setTitleColor_forState(&self, color: Option<&UIColor>, state: UIControlState);
446
447        #[cfg(feature = "UIColor")]
448        #[unsafe(method(setTitleShadowColor:forState:))]
449        #[unsafe(method_family = none)]
450        pub unsafe fn setTitleShadowColor_forState(
451            &self,
452            color: Option<&UIColor>,
453            state: UIControlState,
454        );
455
456        #[cfg(feature = "UIImage")]
457        #[unsafe(method(setImage:forState:))]
458        #[unsafe(method_family = none)]
459        pub unsafe fn setImage_forState(&self, image: Option<&UIImage>, state: UIControlState);
460
461        #[cfg(feature = "UIImage")]
462        #[unsafe(method(setBackgroundImage:forState:))]
463        #[unsafe(method_family = none)]
464        pub unsafe fn setBackgroundImage_forState(
465            &self,
466            image: Option<&UIImage>,
467            state: UIControlState,
468        );
469
470        #[cfg(all(
471            feature = "UIImageConfiguration",
472            feature = "UIImageSymbolConfiguration"
473        ))]
474        #[unsafe(method(setPreferredSymbolConfiguration:forImageInState:))]
475        #[unsafe(method_family = none)]
476        pub unsafe fn setPreferredSymbolConfiguration_forImageInState(
477            &self,
478            configuration: Option<&UIImageSymbolConfiguration>,
479            state: UIControlState,
480        );
481
482        #[unsafe(method(setAttributedTitle:forState:))]
483        #[unsafe(method_family = none)]
484        pub unsafe fn setAttributedTitle_forState(
485            &self,
486            title: Option<&NSAttributedString>,
487            state: UIControlState,
488        );
489
490        #[unsafe(method(titleForState:))]
491        #[unsafe(method_family = none)]
492        pub unsafe fn titleForState(&self, state: UIControlState) -> Option<Retained<NSString>>;
493
494        #[cfg(feature = "UIColor")]
495        #[unsafe(method(titleColorForState:))]
496        #[unsafe(method_family = none)]
497        pub unsafe fn titleColorForState(&self, state: UIControlState)
498            -> Option<Retained<UIColor>>;
499
500        #[cfg(feature = "UIColor")]
501        #[unsafe(method(titleShadowColorForState:))]
502        #[unsafe(method_family = none)]
503        pub unsafe fn titleShadowColorForState(
504            &self,
505            state: UIControlState,
506        ) -> Option<Retained<UIColor>>;
507
508        #[cfg(feature = "UIImage")]
509        #[unsafe(method(imageForState:))]
510        #[unsafe(method_family = none)]
511        pub unsafe fn imageForState(&self, state: UIControlState) -> Option<Retained<UIImage>>;
512
513        #[cfg(feature = "UIImage")]
514        #[unsafe(method(backgroundImageForState:))]
515        #[unsafe(method_family = none)]
516        pub unsafe fn backgroundImageForState(
517            &self,
518            state: UIControlState,
519        ) -> Option<Retained<UIImage>>;
520
521        #[cfg(all(
522            feature = "UIImageConfiguration",
523            feature = "UIImageSymbolConfiguration"
524        ))]
525        #[unsafe(method(preferredSymbolConfigurationForImageInState:))]
526        #[unsafe(method_family = none)]
527        pub unsafe fn preferredSymbolConfigurationForImageInState(
528            &self,
529            state: UIControlState,
530        ) -> Option<Retained<UIImageSymbolConfiguration>>;
531
532        #[unsafe(method(attributedTitleForState:))]
533        #[unsafe(method_family = none)]
534        pub unsafe fn attributedTitleForState(
535            &self,
536            state: UIControlState,
537        ) -> Option<Retained<NSAttributedString>>;
538
539        #[unsafe(method(currentTitle))]
540        #[unsafe(method_family = none)]
541        pub unsafe fn currentTitle(&self) -> Option<Retained<NSString>>;
542
543        #[cfg(feature = "UIColor")]
544        #[unsafe(method(currentTitleColor))]
545        #[unsafe(method_family = none)]
546        pub unsafe fn currentTitleColor(&self) -> Retained<UIColor>;
547
548        #[cfg(feature = "UIColor")]
549        #[unsafe(method(currentTitleShadowColor))]
550        #[unsafe(method_family = none)]
551        pub unsafe fn currentTitleShadowColor(&self) -> Option<Retained<UIColor>>;
552
553        #[cfg(feature = "UIImage")]
554        #[unsafe(method(currentImage))]
555        #[unsafe(method_family = none)]
556        pub unsafe fn currentImage(&self) -> Option<Retained<UIImage>>;
557
558        #[cfg(feature = "UIImage")]
559        #[unsafe(method(currentBackgroundImage))]
560        #[unsafe(method_family = none)]
561        pub unsafe fn currentBackgroundImage(&self) -> Option<Retained<UIImage>>;
562
563        #[cfg(all(
564            feature = "UIImageConfiguration",
565            feature = "UIImageSymbolConfiguration"
566        ))]
567        #[unsafe(method(currentPreferredSymbolConfiguration))]
568        #[unsafe(method_family = none)]
569        pub unsafe fn currentPreferredSymbolConfiguration(
570            &self,
571        ) -> Option<Retained<UIImageSymbolConfiguration>>;
572
573        #[unsafe(method(currentAttributedTitle))]
574        #[unsafe(method_family = none)]
575        pub unsafe fn currentAttributedTitle(&self) -> Option<Retained<NSAttributedString>>;
576
577        #[cfg(feature = "UILabel")]
578        #[unsafe(method(titleLabel))]
579        #[unsafe(method_family = none)]
580        pub unsafe fn titleLabel(&self) -> Option<Retained<UILabel>>;
581
582        #[cfg(feature = "UIImageView")]
583        #[unsafe(method(imageView))]
584        #[unsafe(method_family = none)]
585        pub unsafe fn imageView(&self) -> Option<Retained<UIImageView>>;
586
587        #[cfg(feature = "UILabel")]
588        /// The label used to display the subtitle, when present.
589        #[unsafe(method(subtitleLabel))]
590        #[unsafe(method_family = none)]
591        pub unsafe fn subtitleLabel(&self) -> Option<Retained<UILabel>>;
592    );
593}
594
595/// Methods declared on superclass `NSObject`.
596#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
597impl UIButton {
598    extern_methods!(
599        #[unsafe(method(init))]
600        #[unsafe(method_family = init)]
601        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
602
603        #[unsafe(method(new))]
604        #[unsafe(method_family = new)]
605        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
606    );
607}
608
609#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
610impl UIButton {
611    extern_methods!(
612        #[cfg(feature = "UIFont")]
613        #[deprecated = "Specify an attributed title with a custom font"]
614        #[unsafe(method(font))]
615        #[unsafe(method_family = none)]
616        pub unsafe fn font(&self) -> Retained<UIFont>;
617
618        #[cfg(feature = "UIFont")]
619        /// Setter for [`font`][Self::font].
620        #[deprecated = "Specify an attributed title with a custom font"]
621        #[unsafe(method(setFont:))]
622        #[unsafe(method_family = none)]
623        pub unsafe fn setFont(&self, font: &UIFont);
624
625        #[cfg(feature = "NSParagraphStyle")]
626        #[deprecated = "Specify an attributed title with a customized paragraph style"]
627        #[unsafe(method(lineBreakMode))]
628        #[unsafe(method_family = none)]
629        pub unsafe fn lineBreakMode(&self) -> NSLineBreakMode;
630
631        #[cfg(feature = "NSParagraphStyle")]
632        /// Setter for [`lineBreakMode`][Self::lineBreakMode].
633        #[deprecated = "Specify an attributed title with a customized paragraph style"]
634        #[unsafe(method(setLineBreakMode:))]
635        #[unsafe(method_family = none)]
636        pub unsafe fn setLineBreakMode(&self, line_break_mode: NSLineBreakMode);
637
638        #[cfg(feature = "objc2-core-foundation")]
639        #[deprecated = "Specify an attributed title with a customized shadow style"]
640        #[unsafe(method(titleShadowOffset))]
641        #[unsafe(method_family = none)]
642        pub unsafe fn titleShadowOffset(&self) -> CGSize;
643
644        #[cfg(feature = "objc2-core-foundation")]
645        /// Setter for [`titleShadowOffset`][Self::titleShadowOffset].
646        #[deprecated = "Specify an attributed title with a customized shadow style"]
647        #[unsafe(method(setTitleShadowOffset:))]
648        #[unsafe(method_family = none)]
649        pub unsafe fn setTitleShadowOffset(&self, title_shadow_offset: CGSize);
650
651        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
652        #[deprecated = "This property is ignored when using UIButtonConfiguration"]
653        #[unsafe(method(contentEdgeInsets))]
654        #[unsafe(method_family = none)]
655        pub unsafe fn contentEdgeInsets(&self) -> UIEdgeInsets;
656
657        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
658        /// Setter for [`contentEdgeInsets`][Self::contentEdgeInsets].
659        #[deprecated = "This property is ignored when using UIButtonConfiguration"]
660        #[unsafe(method(setContentEdgeInsets:))]
661        #[unsafe(method_family = none)]
662        pub unsafe fn setContentEdgeInsets(&self, content_edge_insets: UIEdgeInsets);
663
664        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
665        #[deprecated = "This property is ignored when using UIButtonConfiguration"]
666        #[unsafe(method(titleEdgeInsets))]
667        #[unsafe(method_family = none)]
668        pub unsafe fn titleEdgeInsets(&self) -> UIEdgeInsets;
669
670        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
671        /// Setter for [`titleEdgeInsets`][Self::titleEdgeInsets].
672        #[deprecated = "This property is ignored when using UIButtonConfiguration"]
673        #[unsafe(method(setTitleEdgeInsets:))]
674        #[unsafe(method_family = none)]
675        pub unsafe fn setTitleEdgeInsets(&self, title_edge_insets: UIEdgeInsets);
676
677        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
678        #[deprecated = "This property is ignored when using UIButtonConfiguration"]
679        #[unsafe(method(imageEdgeInsets))]
680        #[unsafe(method_family = none)]
681        pub unsafe fn imageEdgeInsets(&self) -> UIEdgeInsets;
682
683        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
684        /// Setter for [`imageEdgeInsets`][Self::imageEdgeInsets].
685        #[deprecated = "This property is ignored when using UIButtonConfiguration"]
686        #[unsafe(method(setImageEdgeInsets:))]
687        #[unsafe(method_family = none)]
688        pub unsafe fn setImageEdgeInsets(&self, image_edge_insets: UIEdgeInsets);
689
690        #[deprecated = "This property is ignored when using UIButtonConfiguration, you may customize to replicate this behavior via a configurationUpdateHandler"]
691        #[unsafe(method(reversesTitleShadowWhenHighlighted))]
692        #[unsafe(method_family = none)]
693        pub unsafe fn reversesTitleShadowWhenHighlighted(&self) -> bool;
694
695        /// Setter for [`reversesTitleShadowWhenHighlighted`][Self::reversesTitleShadowWhenHighlighted].
696        #[deprecated = "This property is ignored when using UIButtonConfiguration, you may customize to replicate this behavior via a configurationUpdateHandler"]
697        #[unsafe(method(setReversesTitleShadowWhenHighlighted:))]
698        #[unsafe(method_family = none)]
699        pub unsafe fn setReversesTitleShadowWhenHighlighted(
700            &self,
701            reverses_title_shadow_when_highlighted: bool,
702        );
703
704        #[deprecated = "This property is ignored when using UIButtonConfiguration, you may customize to replicate this behavior via a configurationUpdateHandler"]
705        #[unsafe(method(adjustsImageWhenHighlighted))]
706        #[unsafe(method_family = none)]
707        pub unsafe fn adjustsImageWhenHighlighted(&self) -> bool;
708
709        /// Setter for [`adjustsImageWhenHighlighted`][Self::adjustsImageWhenHighlighted].
710        #[deprecated = "This property is ignored when using UIButtonConfiguration, you may customize to replicate this behavior via a configurationUpdateHandler"]
711        #[unsafe(method(setAdjustsImageWhenHighlighted:))]
712        #[unsafe(method_family = none)]
713        pub unsafe fn setAdjustsImageWhenHighlighted(&self, adjusts_image_when_highlighted: bool);
714
715        #[deprecated = "This property is ignored when using UIButtonConfiguration, you may customize to replicate this behavior via a configurationUpdateHandler"]
716        #[unsafe(method(adjustsImageWhenDisabled))]
717        #[unsafe(method_family = none)]
718        pub unsafe fn adjustsImageWhenDisabled(&self) -> bool;
719
720        /// Setter for [`adjustsImageWhenDisabled`][Self::adjustsImageWhenDisabled].
721        #[deprecated = "This property is ignored when using UIButtonConfiguration, you may customize to replicate this behavior via a configurationUpdateHandler"]
722        #[unsafe(method(setAdjustsImageWhenDisabled:))]
723        #[unsafe(method_family = none)]
724        pub unsafe fn setAdjustsImageWhenDisabled(&self, adjusts_image_when_disabled: bool);
725
726        #[deprecated = "This property is ignored when using UIButtonConfiguration"]
727        #[unsafe(method(showsTouchWhenHighlighted))]
728        #[unsafe(method_family = none)]
729        pub unsafe fn showsTouchWhenHighlighted(&self) -> bool;
730
731        /// Setter for [`showsTouchWhenHighlighted`][Self::showsTouchWhenHighlighted].
732        #[deprecated = "This property is ignored when using UIButtonConfiguration"]
733        #[unsafe(method(setShowsTouchWhenHighlighted:))]
734        #[unsafe(method_family = none)]
735        pub unsafe fn setShowsTouchWhenHighlighted(&self, shows_touch_when_highlighted: bool);
736
737        #[cfg(feature = "objc2-core-foundation")]
738        #[deprecated = "Override layoutSubviews, call super, and position views as you desire."]
739        #[unsafe(method(backgroundRectForBounds:))]
740        #[unsafe(method_family = none)]
741        pub unsafe fn backgroundRectForBounds(&self, bounds: CGRect) -> CGRect;
742
743        #[cfg(feature = "objc2-core-foundation")]
744        #[deprecated = "Override layoutSubviews, call super, and position views as you desire."]
745        #[unsafe(method(contentRectForBounds:))]
746        #[unsafe(method_family = none)]
747        pub unsafe fn contentRectForBounds(&self, bounds: CGRect) -> CGRect;
748
749        #[cfg(feature = "objc2-core-foundation")]
750        #[deprecated = "Override layoutSubviews, call super, and position views as you desire."]
751        #[unsafe(method(titleRectForContentRect:))]
752        #[unsafe(method_family = none)]
753        pub unsafe fn titleRectForContentRect(&self, content_rect: CGRect) -> CGRect;
754
755        #[cfg(feature = "objc2-core-foundation")]
756        #[deprecated = "Override layoutSubviews, call super, and position views as you desire."]
757        #[unsafe(method(imageRectForContentRect:))]
758        #[unsafe(method_family = none)]
759        pub unsafe fn imageRectForContentRect(&self, content_rect: CGRect) -> CGRect;
760    );
761}
762
763/// SpringLoading.
764#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
765impl UIButton {
766    extern_methods!();
767}
768
769#[cfg(all(
770    feature = "UIControl",
771    feature = "UIResponder",
772    feature = "UISpringLoadedInteractionSupporting",
773    feature = "UIView"
774))]
775unsafe impl UISpringLoadedInteractionSupporting for UIButton {}