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::DynBlock<
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::DynBlock<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"))]
115extern_conformance!(
116    unsafe impl CALayerDelegate for UIButton {}
117);
118
119#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
120extern_conformance!(
121    unsafe impl NSCoding for UIButton {}
122);
123
124#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
125extern_conformance!(
126    unsafe impl NSObjectProtocol for UIButton {}
127);
128
129#[cfg(all(
130    feature = "UIAppearance",
131    feature = "UIControl",
132    feature = "UIResponder",
133    feature = "UIView"
134))]
135extern_conformance!(
136    unsafe impl UIAppearance for UIButton {}
137);
138
139#[cfg(all(
140    feature = "UIAppearance",
141    feature = "UIControl",
142    feature = "UIResponder",
143    feature = "UIView"
144))]
145extern_conformance!(
146    unsafe impl UIAppearanceContainer for UIButton {}
147);
148
149#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
150extern_conformance!(
151    unsafe impl UICoordinateSpace for UIButton {}
152);
153
154#[cfg(all(
155    feature = "UIControl",
156    feature = "UIDynamicBehavior",
157    feature = "UIResponder",
158    feature = "UIView"
159))]
160extern_conformance!(
161    unsafe impl UIDynamicItem for UIButton {}
162);
163
164#[cfg(all(
165    feature = "UIControl",
166    feature = "UIFocus",
167    feature = "UIResponder",
168    feature = "UIView"
169))]
170extern_conformance!(
171    unsafe impl UIFocusEnvironment for UIButton {}
172);
173
174#[cfg(all(
175    feature = "UIControl",
176    feature = "UIFocus",
177    feature = "UIResponder",
178    feature = "UIView"
179))]
180extern_conformance!(
181    unsafe impl UIFocusItem for UIButton {}
182);
183
184#[cfg(all(
185    feature = "UIControl",
186    feature = "UIFocus",
187    feature = "UIResponder",
188    feature = "UIView"
189))]
190extern_conformance!(
191    unsafe impl UIFocusItemContainer for UIButton {}
192);
193
194#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
195extern_conformance!(
196    unsafe impl UIResponderStandardEditActions for UIButton {}
197);
198
199#[cfg(all(
200    feature = "UIControl",
201    feature = "UIResponder",
202    feature = "UITraitCollection",
203    feature = "UIView"
204))]
205extern_conformance!(
206    unsafe impl UITraitEnvironment for UIButton {}
207);
208
209#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
210impl UIButton {
211    extern_methods!(
212        #[cfg(feature = "objc2-core-foundation")]
213        #[unsafe(method(initWithFrame:))]
214        #[unsafe(method_family = init)]
215        pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
216
217        /// # Safety
218        ///
219        /// `coder` possibly has further requirements.
220        #[unsafe(method(initWithCoder:))]
221        #[unsafe(method_family = init)]
222        pub unsafe fn initWithCoder(
223            this: Allocated<Self>,
224            coder: &NSCoder,
225        ) -> Option<Retained<Self>>;
226
227        #[cfg(all(
228            feature = "UIAction",
229            feature = "UIMenuElement",
230            feature = "objc2-core-foundation"
231        ))]
232        /// Initializes a custom button, registers primaryAction for the UIControlEventPrimaryActionTriggered control event, and uses primaryAction's title
233        /// &
234        /// image as the button's title
235        /// &
236        /// image.
237        #[unsafe(method(initWithFrame:primaryAction:))]
238        #[unsafe(method_family = init)]
239        pub fn initWithFrame_primaryAction(
240            this: Allocated<Self>,
241            frame: CGRect,
242            primary_action: Option<&UIAction>,
243        ) -> Retained<Self>;
244
245        #[unsafe(method(buttonWithType:))]
246        #[unsafe(method_family = none)]
247        pub fn buttonWithType(button_type: UIButtonType, mtm: MainThreadMarker) -> Retained<Self>;
248
249        #[cfg(feature = "UIImage")]
250        /// # Safety
251        ///
252        /// - `target` should be of the correct type.
253        /// - `action` must be a valid selector.
254        #[unsafe(method(systemButtonWithImage:target:action:))]
255        #[unsafe(method_family = none)]
256        pub unsafe fn systemButtonWithImage_target_action(
257            image: &UIImage,
258            target: Option<&AnyObject>,
259            action: Option<Sel>,
260            mtm: MainThreadMarker,
261        ) -> Retained<Self>;
262
263        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
264        /// Creates a system button, registers primaryAction for the UIControlEventPrimaryActionTriggered control event, and uses primaryAction's title
265        /// &
266        /// image as the button's title
267        /// &
268        /// image.
269        #[unsafe(method(systemButtonWithPrimaryAction:))]
270        #[unsafe(method_family = none)]
271        pub fn systemButtonWithPrimaryAction(
272            primary_action: Option<&UIAction>,
273            mtm: MainThreadMarker,
274        ) -> Retained<Self>;
275
276        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
277        /// Creates a button of the given type, registers primaryAction for the UIControlEventPrimaryActionTriggered control event, and if appropriate uses primaryAction's title
278        /// &
279        /// image as the button's title
280        /// &
281        /// image.
282        #[unsafe(method(buttonWithType:primaryAction:))]
283        #[unsafe(method_family = none)]
284        pub fn buttonWithType_primaryAction(
285            button_type: UIButtonType,
286            primary_action: Option<&UIAction>,
287            mtm: MainThreadMarker,
288        ) -> Retained<Self>;
289
290        #[cfg(all(
291            feature = "UIAction",
292            feature = "UIButtonConfiguration",
293            feature = "UIMenuElement"
294        ))]
295        /// 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`
296        #[unsafe(method(buttonWithConfiguration:primaryAction:))]
297        #[unsafe(method_family = none)]
298        pub fn buttonWithConfiguration_primaryAction(
299            configuration: &UIButtonConfiguration,
300            primary_action: Option<&UIAction>,
301        ) -> Retained<Self>;
302
303        #[cfg(feature = "UIButtonConfiguration")]
304        /// 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.
305        #[unsafe(method(configuration))]
306        #[unsafe(method_family = none)]
307        pub fn configuration(&self) -> Option<Retained<UIButtonConfiguration>>;
308
309        #[cfg(feature = "UIButtonConfiguration")]
310        /// Setter for [`configuration`][Self::configuration].
311        ///
312        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
313        #[unsafe(method(setConfiguration:))]
314        #[unsafe(method_family = none)]
315        pub fn setConfiguration(&self, configuration: Option<&UIButtonConfiguration>);
316
317        /// 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.
318        #[unsafe(method(setNeedsUpdateConfiguration))]
319        #[unsafe(method_family = none)]
320        pub fn setNeedsUpdateConfiguration(&self);
321
322        /// Subclasses should override this method and update the button's `configuration`. This method should not be called directly, use `setNeedsUpdateConfiguration` to request an update.
323        #[unsafe(method(updateConfiguration))]
324        #[unsafe(method_family = none)]
325        pub fn updateConfiguration(&self);
326
327        #[cfg(feature = "block2")]
328        /// 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`
329        ///
330        /// # Safety
331        ///
332        /// The returned block's argument must be a valid pointer.
333        #[unsafe(method(configurationUpdateHandler))]
334        #[unsafe(method_family = none)]
335        pub unsafe fn configurationUpdateHandler(&self) -> UIButtonConfigurationUpdateHandler;
336
337        #[cfg(feature = "block2")]
338        /// Setter for [`configurationUpdateHandler`][Self::configurationUpdateHandler].
339        ///
340        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
341        ///
342        /// # Safety
343        ///
344        /// `configuration_update_handler` must be a valid pointer or null.
345        #[unsafe(method(setConfigurationUpdateHandler:))]
346        #[unsafe(method_family = none)]
347        pub unsafe fn setConfigurationUpdateHandler(
348            &self,
349            configuration_update_handler: UIButtonConfigurationUpdateHandler,
350        );
351
352        /// 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.
353        #[unsafe(method(automaticallyUpdatesConfiguration))]
354        #[unsafe(method_family = none)]
355        pub fn automaticallyUpdatesConfiguration(&self) -> bool;
356
357        /// Setter for [`automaticallyUpdatesConfiguration`][Self::automaticallyUpdatesConfiguration].
358        #[unsafe(method(setAutomaticallyUpdatesConfiguration:))]
359        #[unsafe(method_family = none)]
360        pub fn setAutomaticallyUpdatesConfiguration(
361            &self,
362            automatically_updates_configuration: bool,
363        );
364
365        #[cfg(feature = "UIColor")]
366        #[unsafe(method(tintColor))]
367        #[unsafe(method_family = none)]
368        pub fn tintColor(&self) -> Option<Retained<UIColor>>;
369
370        #[cfg(feature = "UIColor")]
371        /// Setter for [`tintColor`][Self::tintColor].
372        ///
373        /// # Safety
374        ///
375        /// `tint_color` might not allow `None`.
376        #[unsafe(method(setTintColor:))]
377        #[unsafe(method_family = none)]
378        pub unsafe fn setTintColor(&self, tint_color: Option<&UIColor>);
379
380        #[unsafe(method(buttonType))]
381        #[unsafe(method_family = none)]
382        pub fn buttonType(&self) -> UIButtonType;
383
384        /// If pointer effects are enabled for the button, this will return true when an effect is active.
385        #[unsafe(method(isHovered))]
386        #[unsafe(method_family = none)]
387        pub fn isHovered(&self) -> bool;
388
389        /// Returns true while the button is presenting a menu.
390        #[unsafe(method(isHeld))]
391        #[unsafe(method_family = none)]
392        pub fn isHeld(&self) -> bool;
393
394        #[unsafe(method(role))]
395        #[unsafe(method_family = none)]
396        pub fn role(&self) -> UIButtonRole;
397
398        /// Setter for [`role`][Self::role].
399        #[unsafe(method(setRole:))]
400        #[unsafe(method_family = none)]
401        pub fn setRole(&self, role: UIButtonRole);
402
403        /// Enables this button's built-in pointer interaction.
404        #[unsafe(method(isPointerInteractionEnabled))]
405        #[unsafe(method_family = none)]
406        pub fn isPointerInteractionEnabled(&self) -> bool;
407
408        /// Setter for [`isPointerInteractionEnabled`][Self::isPointerInteractionEnabled].
409        #[unsafe(method(setPointerInteractionEnabled:))]
410        #[unsafe(method_family = none)]
411        pub fn setPointerInteractionEnabled(&self, pointer_interaction_enabled: bool);
412
413        #[cfg(all(
414            feature = "UIHoverStyle",
415            feature = "UIPointerStyle",
416            feature = "block2"
417        ))]
418        /// Called when the system pointer hovers over this button if its pointer interaction is enabled. The
419        /// system calls this block with a proposed UIPointerEffect and UIPointerShape. You may use them to construct
420        /// a customized version of the system provided style or return an entirely custom one.
421        /// Setting this property automatically enables the button's pointer interaction and sets
422        /// `pointerInteractionEnabled`to true.
423        ///
424        /// # Safety
425        ///
426        /// - The returned block's argument 1 must be a valid pointer.
427        /// - The returned block's argument 2 must be a valid pointer.
428        /// - The returned block's argument 3 must be a valid pointer.
429        #[unsafe(method(pointerStyleProvider))]
430        #[unsafe(method_family = none)]
431        pub unsafe fn pointerStyleProvider(&self) -> UIButtonPointerStyleProvider;
432
433        #[cfg(all(
434            feature = "UIHoverStyle",
435            feature = "UIPointerStyle",
436            feature = "block2"
437        ))]
438        /// Setter for [`pointerStyleProvider`][Self::pointerStyleProvider].
439        ///
440        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
441        ///
442        /// # Safety
443        ///
444        /// `pointer_style_provider` must be a valid pointer or null.
445        #[unsafe(method(setPointerStyleProvider:))]
446        #[unsafe(method_family = none)]
447        pub unsafe fn setPointerStyleProvider(
448            &self,
449            pointer_style_provider: UIButtonPointerStyleProvider,
450        );
451
452        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
453        /// 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.
454        #[unsafe(method(menu))]
455        #[unsafe(method_family = none)]
456        pub fn menu(&self) -> Option<Retained<UIMenu>>;
457
458        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
459        /// Setter for [`menu`][Self::menu].
460        ///
461        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
462        #[unsafe(method(setMenu:))]
463        #[unsafe(method_family = none)]
464        pub fn setMenu(&self, menu: Option<&UIMenu>);
465
466        #[cfg(feature = "UIContextMenuConfiguration")]
467        /// Preferred menu element ordering strategy for menus displayed by this button.
468        #[unsafe(method(preferredMenuElementOrder))]
469        #[unsafe(method_family = none)]
470        pub fn preferredMenuElementOrder(&self) -> UIContextMenuConfigurationElementOrder;
471
472        #[cfg(feature = "UIContextMenuConfiguration")]
473        /// Setter for [`preferredMenuElementOrder`][Self::preferredMenuElementOrder].
474        #[unsafe(method(setPreferredMenuElementOrder:))]
475        #[unsafe(method_family = none)]
476        pub fn setPreferredMenuElementOrder(
477            &self,
478            preferred_menu_element_order: UIContextMenuConfigurationElementOrder,
479        );
480
481        /// Indicates if the button changes selection as its primary action.
482        /// This shows the menu as options for selection if a menu is populated and showsMenuAsPrimaryAction is enabled.
483        /// If no menu is provided or it is not the primary action, UIControlStateSelected is toggled on and off for the primary action.
484        #[unsafe(method(changesSelectionAsPrimaryAction))]
485        #[unsafe(method_family = none)]
486        pub fn changesSelectionAsPrimaryAction(&self) -> bool;
487
488        /// Setter for [`changesSelectionAsPrimaryAction`][Self::changesSelectionAsPrimaryAction].
489        #[unsafe(method(setChangesSelectionAsPrimaryAction:))]
490        #[unsafe(method_family = none)]
491        pub fn setChangesSelectionAsPrimaryAction(&self, changes_selection_as_primary_action: bool);
492
493        #[unsafe(method(setTitle:forState:))]
494        #[unsafe(method_family = none)]
495        pub fn setTitle_forState(&self, title: Option<&NSString>, state: UIControlState);
496
497        #[cfg(feature = "UIColor")]
498        #[unsafe(method(setTitleColor:forState:))]
499        #[unsafe(method_family = none)]
500        pub fn setTitleColor_forState(&self, color: Option<&UIColor>, state: UIControlState);
501
502        #[cfg(feature = "UIColor")]
503        #[unsafe(method(setTitleShadowColor:forState:))]
504        #[unsafe(method_family = none)]
505        pub fn setTitleShadowColor_forState(&self, color: Option<&UIColor>, state: UIControlState);
506
507        #[cfg(feature = "UIImage")]
508        #[unsafe(method(setImage:forState:))]
509        #[unsafe(method_family = none)]
510        pub fn setImage_forState(&self, image: Option<&UIImage>, state: UIControlState);
511
512        #[cfg(feature = "UIImage")]
513        #[unsafe(method(setBackgroundImage:forState:))]
514        #[unsafe(method_family = none)]
515        pub fn setBackgroundImage_forState(&self, image: Option<&UIImage>, state: UIControlState);
516
517        #[cfg(all(
518            feature = "UIImageConfiguration",
519            feature = "UIImageSymbolConfiguration"
520        ))]
521        #[unsafe(method(setPreferredSymbolConfiguration:forImageInState:))]
522        #[unsafe(method_family = none)]
523        pub fn setPreferredSymbolConfiguration_forImageInState(
524            &self,
525            configuration: Option<&UIImageSymbolConfiguration>,
526            state: UIControlState,
527        );
528
529        #[unsafe(method(setAttributedTitle:forState:))]
530        #[unsafe(method_family = none)]
531        pub fn setAttributedTitle_forState(
532            &self,
533            title: Option<&NSAttributedString>,
534            state: UIControlState,
535        );
536
537        #[unsafe(method(titleForState:))]
538        #[unsafe(method_family = none)]
539        pub fn titleForState(&self, state: UIControlState) -> Option<Retained<NSString>>;
540
541        #[cfg(feature = "UIColor")]
542        #[unsafe(method(titleColorForState:))]
543        #[unsafe(method_family = none)]
544        pub fn titleColorForState(&self, state: UIControlState) -> Option<Retained<UIColor>>;
545
546        #[cfg(feature = "UIColor")]
547        #[unsafe(method(titleShadowColorForState:))]
548        #[unsafe(method_family = none)]
549        pub fn titleShadowColorForState(&self, state: UIControlState) -> Option<Retained<UIColor>>;
550
551        #[cfg(feature = "UIImage")]
552        #[unsafe(method(imageForState:))]
553        #[unsafe(method_family = none)]
554        pub fn imageForState(&self, state: UIControlState) -> Option<Retained<UIImage>>;
555
556        #[cfg(feature = "UIImage")]
557        #[unsafe(method(backgroundImageForState:))]
558        #[unsafe(method_family = none)]
559        pub fn backgroundImageForState(&self, state: UIControlState) -> Option<Retained<UIImage>>;
560
561        #[cfg(all(
562            feature = "UIImageConfiguration",
563            feature = "UIImageSymbolConfiguration"
564        ))]
565        #[unsafe(method(preferredSymbolConfigurationForImageInState:))]
566        #[unsafe(method_family = none)]
567        pub fn preferredSymbolConfigurationForImageInState(
568            &self,
569            state: UIControlState,
570        ) -> Option<Retained<UIImageSymbolConfiguration>>;
571
572        #[unsafe(method(attributedTitleForState:))]
573        #[unsafe(method_family = none)]
574        pub fn attributedTitleForState(
575            &self,
576            state: UIControlState,
577        ) -> Option<Retained<NSAttributedString>>;
578
579        #[unsafe(method(currentTitle))]
580        #[unsafe(method_family = none)]
581        pub fn currentTitle(&self) -> Option<Retained<NSString>>;
582
583        #[cfg(feature = "UIColor")]
584        #[unsafe(method(currentTitleColor))]
585        #[unsafe(method_family = none)]
586        pub fn currentTitleColor(&self) -> Retained<UIColor>;
587
588        #[cfg(feature = "UIColor")]
589        #[unsafe(method(currentTitleShadowColor))]
590        #[unsafe(method_family = none)]
591        pub fn currentTitleShadowColor(&self) -> Option<Retained<UIColor>>;
592
593        #[cfg(feature = "UIImage")]
594        #[unsafe(method(currentImage))]
595        #[unsafe(method_family = none)]
596        pub fn currentImage(&self) -> Option<Retained<UIImage>>;
597
598        #[cfg(feature = "UIImage")]
599        #[unsafe(method(currentBackgroundImage))]
600        #[unsafe(method_family = none)]
601        pub fn currentBackgroundImage(&self) -> Option<Retained<UIImage>>;
602
603        #[cfg(all(
604            feature = "UIImageConfiguration",
605            feature = "UIImageSymbolConfiguration"
606        ))]
607        #[unsafe(method(currentPreferredSymbolConfiguration))]
608        #[unsafe(method_family = none)]
609        pub fn currentPreferredSymbolConfiguration(
610            &self,
611        ) -> Option<Retained<UIImageSymbolConfiguration>>;
612
613        #[unsafe(method(currentAttributedTitle))]
614        #[unsafe(method_family = none)]
615        pub fn currentAttributedTitle(&self) -> Option<Retained<NSAttributedString>>;
616
617        #[cfg(feature = "UILabel")]
618        #[unsafe(method(titleLabel))]
619        #[unsafe(method_family = none)]
620        pub fn titleLabel(&self) -> Option<Retained<UILabel>>;
621
622        #[cfg(feature = "UIImageView")]
623        #[unsafe(method(imageView))]
624        #[unsafe(method_family = none)]
625        pub fn imageView(&self) -> Option<Retained<UIImageView>>;
626
627        #[cfg(feature = "UILabel")]
628        /// The label used to display the subtitle, when present.
629        #[unsafe(method(subtitleLabel))]
630        #[unsafe(method_family = none)]
631        pub fn subtitleLabel(&self) -> Option<Retained<UILabel>>;
632    );
633}
634
635/// Methods declared on superclass `UIView`.
636#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
637impl UIButton {
638    extern_methods!(
639        #[unsafe(method(init))]
640        #[unsafe(method_family = init)]
641        pub fn init(this: Allocated<Self>) -> Retained<Self>;
642    );
643}
644
645/// Methods declared on superclass `NSObject`.
646#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
647impl UIButton {
648    extern_methods!(
649        #[unsafe(method(new))]
650        #[unsafe(method_family = new)]
651        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
652    );
653}
654
655#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
656impl UIButton {
657    extern_methods!(
658        #[cfg(feature = "UIFont")]
659        #[deprecated = "Specify an attributed title with a custom font"]
660        #[unsafe(method(font))]
661        #[unsafe(method_family = none)]
662        pub fn font(&self) -> Retained<UIFont>;
663
664        #[cfg(feature = "UIFont")]
665        /// Setter for [`font`][Self::font].
666        #[deprecated = "Specify an attributed title with a custom font"]
667        #[unsafe(method(setFont:))]
668        #[unsafe(method_family = none)]
669        pub fn setFont(&self, font: &UIFont);
670
671        #[cfg(feature = "NSParagraphStyle")]
672        #[deprecated = "Specify an attributed title with a customized paragraph style"]
673        #[unsafe(method(lineBreakMode))]
674        #[unsafe(method_family = none)]
675        pub fn lineBreakMode(&self) -> NSLineBreakMode;
676
677        #[cfg(feature = "NSParagraphStyle")]
678        /// Setter for [`lineBreakMode`][Self::lineBreakMode].
679        #[deprecated = "Specify an attributed title with a customized paragraph style"]
680        #[unsafe(method(setLineBreakMode:))]
681        #[unsafe(method_family = none)]
682        pub fn setLineBreakMode(&self, line_break_mode: NSLineBreakMode);
683
684        #[cfg(feature = "objc2-core-foundation")]
685        #[deprecated = "Specify an attributed title with a customized shadow style"]
686        #[unsafe(method(titleShadowOffset))]
687        #[unsafe(method_family = none)]
688        pub fn titleShadowOffset(&self) -> CGSize;
689
690        #[cfg(feature = "objc2-core-foundation")]
691        /// Setter for [`titleShadowOffset`][Self::titleShadowOffset].
692        #[deprecated = "Specify an attributed title with a customized shadow style"]
693        #[unsafe(method(setTitleShadowOffset:))]
694        #[unsafe(method_family = none)]
695        pub fn setTitleShadowOffset(&self, title_shadow_offset: CGSize);
696
697        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
698        #[deprecated = "This property is ignored when using UIButtonConfiguration"]
699        #[unsafe(method(contentEdgeInsets))]
700        #[unsafe(method_family = none)]
701        pub fn contentEdgeInsets(&self) -> UIEdgeInsets;
702
703        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
704        /// Setter for [`contentEdgeInsets`][Self::contentEdgeInsets].
705        #[deprecated = "This property is ignored when using UIButtonConfiguration"]
706        #[unsafe(method(setContentEdgeInsets:))]
707        #[unsafe(method_family = none)]
708        pub fn setContentEdgeInsets(&self, content_edge_insets: UIEdgeInsets);
709
710        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
711        #[deprecated = "This property is ignored when using UIButtonConfiguration"]
712        #[unsafe(method(titleEdgeInsets))]
713        #[unsafe(method_family = none)]
714        pub fn titleEdgeInsets(&self) -> UIEdgeInsets;
715
716        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
717        /// Setter for [`titleEdgeInsets`][Self::titleEdgeInsets].
718        #[deprecated = "This property is ignored when using UIButtonConfiguration"]
719        #[unsafe(method(setTitleEdgeInsets:))]
720        #[unsafe(method_family = none)]
721        pub fn setTitleEdgeInsets(&self, title_edge_insets: UIEdgeInsets);
722
723        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
724        #[deprecated = "This property is ignored when using UIButtonConfiguration"]
725        #[unsafe(method(imageEdgeInsets))]
726        #[unsafe(method_family = none)]
727        pub fn imageEdgeInsets(&self) -> UIEdgeInsets;
728
729        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
730        /// Setter for [`imageEdgeInsets`][Self::imageEdgeInsets].
731        #[deprecated = "This property is ignored when using UIButtonConfiguration"]
732        #[unsafe(method(setImageEdgeInsets:))]
733        #[unsafe(method_family = none)]
734        pub fn setImageEdgeInsets(&self, image_edge_insets: UIEdgeInsets);
735
736        #[deprecated = "This property is ignored when using UIButtonConfiguration, you may customize to replicate this behavior via a configurationUpdateHandler"]
737        #[unsafe(method(reversesTitleShadowWhenHighlighted))]
738        #[unsafe(method_family = none)]
739        pub fn reversesTitleShadowWhenHighlighted(&self) -> bool;
740
741        /// Setter for [`reversesTitleShadowWhenHighlighted`][Self::reversesTitleShadowWhenHighlighted].
742        #[deprecated = "This property is ignored when using UIButtonConfiguration, you may customize to replicate this behavior via a configurationUpdateHandler"]
743        #[unsafe(method(setReversesTitleShadowWhenHighlighted:))]
744        #[unsafe(method_family = none)]
745        pub fn setReversesTitleShadowWhenHighlighted(
746            &self,
747            reverses_title_shadow_when_highlighted: bool,
748        );
749
750        #[deprecated = "This property is ignored when using UIButtonConfiguration, you may customize to replicate this behavior via a configurationUpdateHandler"]
751        #[unsafe(method(adjustsImageWhenHighlighted))]
752        #[unsafe(method_family = none)]
753        pub fn adjustsImageWhenHighlighted(&self) -> bool;
754
755        /// Setter for [`adjustsImageWhenHighlighted`][Self::adjustsImageWhenHighlighted].
756        #[deprecated = "This property is ignored when using UIButtonConfiguration, you may customize to replicate this behavior via a configurationUpdateHandler"]
757        #[unsafe(method(setAdjustsImageWhenHighlighted:))]
758        #[unsafe(method_family = none)]
759        pub fn setAdjustsImageWhenHighlighted(&self, adjusts_image_when_highlighted: bool);
760
761        #[deprecated = "This property is ignored when using UIButtonConfiguration, you may customize to replicate this behavior via a configurationUpdateHandler"]
762        #[unsafe(method(adjustsImageWhenDisabled))]
763        #[unsafe(method_family = none)]
764        pub fn adjustsImageWhenDisabled(&self) -> bool;
765
766        /// Setter for [`adjustsImageWhenDisabled`][Self::adjustsImageWhenDisabled].
767        #[deprecated = "This property is ignored when using UIButtonConfiguration, you may customize to replicate this behavior via a configurationUpdateHandler"]
768        #[unsafe(method(setAdjustsImageWhenDisabled:))]
769        #[unsafe(method_family = none)]
770        pub fn setAdjustsImageWhenDisabled(&self, adjusts_image_when_disabled: bool);
771
772        #[deprecated = "This property is ignored when using UIButtonConfiguration"]
773        #[unsafe(method(showsTouchWhenHighlighted))]
774        #[unsafe(method_family = none)]
775        pub fn showsTouchWhenHighlighted(&self) -> bool;
776
777        /// Setter for [`showsTouchWhenHighlighted`][Self::showsTouchWhenHighlighted].
778        #[deprecated = "This property is ignored when using UIButtonConfiguration"]
779        #[unsafe(method(setShowsTouchWhenHighlighted:))]
780        #[unsafe(method_family = none)]
781        pub fn setShowsTouchWhenHighlighted(&self, shows_touch_when_highlighted: bool);
782
783        #[cfg(feature = "objc2-core-foundation")]
784        #[deprecated = "Override layoutSubviews, call super, and position views as you desire."]
785        #[unsafe(method(backgroundRectForBounds:))]
786        #[unsafe(method_family = none)]
787        pub fn backgroundRectForBounds(&self, bounds: CGRect) -> CGRect;
788
789        #[cfg(feature = "objc2-core-foundation")]
790        #[deprecated = "Override layoutSubviews, call super, and position views as you desire."]
791        #[unsafe(method(contentRectForBounds:))]
792        #[unsafe(method_family = none)]
793        pub fn contentRectForBounds(&self, bounds: CGRect) -> CGRect;
794
795        #[cfg(feature = "objc2-core-foundation")]
796        #[deprecated = "Override layoutSubviews, call super, and position views as you desire."]
797        #[unsafe(method(titleRectForContentRect:))]
798        #[unsafe(method_family = none)]
799        pub fn titleRectForContentRect(&self, content_rect: CGRect) -> CGRect;
800
801        #[cfg(feature = "objc2-core-foundation")]
802        #[deprecated = "Override layoutSubviews, call super, and position views as you desire."]
803        #[unsafe(method(imageRectForContentRect:))]
804        #[unsafe(method_family = none)]
805        pub fn imageRectForContentRect(&self, content_rect: CGRect) -> CGRect;
806    );
807}
808
809/// SpringLoading.
810#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
811impl UIButton {
812    extern_methods!();
813}
814
815#[cfg(all(
816    feature = "UIControl",
817    feature = "UIResponder",
818    feature = "UISpringLoadedInteractionSupporting",
819    feature = "UIView"
820))]
821extern_conformance!(
822    unsafe impl UISpringLoadedInteractionSupporting for UIButton {}
823);