objc2_ui_kit/generated/
UIBarButtonItem.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-symbols")]
10use objc2_symbols::*;
11
12use crate::*;
13
14/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uibarbuttonitemstyle?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct UIBarButtonItemStyle(pub NSInteger);
19impl UIBarButtonItemStyle {
20    #[doc(alias = "UIBarButtonItemStylePlain")]
21    pub const Plain: Self = Self(0);
22    /// A button item style for a prominent button.
23    ///
24    /// For example, use this for a button that completes or finalizes some task.
25    /// Buttons with this style will not be visually grouped with other items
26    /// in a navigation bar or toolbar, and will also have other styling changes
27    /// appropriate to their context to indicate their prominence.
28    #[doc(alias = "UIBarButtonItemStyleProminent")]
29    pub const Prominent: Self = Self(2);
30    /// A button item style for a prominent button.
31    ///
32    /// For example, use this for a button that completes or finalizes some task.
33    /// Buttons with this style will not be visually grouped with other items
34    /// in a navigation bar or toolbar, and will also have other styling changes
35    /// appropriate to their context to indicate their prominence.
36    #[doc(alias = "UIBarButtonItemStyleBordered")]
37    #[deprecated]
38    pub const Bordered: Self = Self(1);
39    /// A button item style for a prominent button.
40    ///
41    /// For example, use this for a button that completes or finalizes some task.
42    /// Buttons with this style will not be visually grouped with other items
43    /// in a navigation bar or toolbar, and will also have other styling changes
44    /// appropriate to their context to indicate their prominence.
45    #[doc(alias = "UIBarButtonItemStyleDone")]
46    #[deprecated]
47    pub const Done: Self = Self(UIBarButtonItemStyle::Prominent.0);
48}
49
50unsafe impl Encode for UIBarButtonItemStyle {
51    const ENCODING: Encoding = NSInteger::ENCODING;
52}
53
54unsafe impl RefEncode for UIBarButtonItemStyle {
55    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
56}
57
58/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uibarbuttonsystemitem?language=objc)
59// NS_ENUM
60#[repr(transparent)]
61#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
62pub struct UIBarButtonSystemItem(pub NSInteger);
63impl UIBarButtonSystemItem {
64    #[doc(alias = "UIBarButtonSystemItemDone")]
65    pub const Done: Self = Self(0);
66    #[doc(alias = "UIBarButtonSystemItemCancel")]
67    pub const Cancel: Self = Self(1);
68    #[doc(alias = "UIBarButtonSystemItemEdit")]
69    pub const Edit: Self = Self(2);
70    #[doc(alias = "UIBarButtonSystemItemSave")]
71    pub const Save: Self = Self(3);
72    #[doc(alias = "UIBarButtonSystemItemAdd")]
73    pub const Add: Self = Self(4);
74    #[doc(alias = "UIBarButtonSystemItemFlexibleSpace")]
75    pub const FlexibleSpace: Self = Self(5);
76    #[doc(alias = "UIBarButtonSystemItemFixedSpace")]
77    pub const FixedSpace: Self = Self(6);
78    #[doc(alias = "UIBarButtonSystemItemCompose")]
79    pub const Compose: Self = Self(7);
80    #[doc(alias = "UIBarButtonSystemItemReply")]
81    pub const Reply: Self = Self(8);
82    #[doc(alias = "UIBarButtonSystemItemAction")]
83    pub const Action: Self = Self(9);
84    #[doc(alias = "UIBarButtonSystemItemOrganize")]
85    pub const Organize: Self = Self(10);
86    #[doc(alias = "UIBarButtonSystemItemBookmarks")]
87    pub const Bookmarks: Self = Self(11);
88    #[doc(alias = "UIBarButtonSystemItemSearch")]
89    pub const Search: Self = Self(12);
90    #[doc(alias = "UIBarButtonSystemItemRefresh")]
91    pub const Refresh: Self = Self(13);
92    #[doc(alias = "UIBarButtonSystemItemStop")]
93    pub const Stop: Self = Self(14);
94    #[doc(alias = "UIBarButtonSystemItemCamera")]
95    pub const Camera: Self = Self(15);
96    #[doc(alias = "UIBarButtonSystemItemTrash")]
97    pub const Trash: Self = Self(16);
98    #[doc(alias = "UIBarButtonSystemItemPlay")]
99    pub const Play: Self = Self(17);
100    #[doc(alias = "UIBarButtonSystemItemPause")]
101    pub const Pause: Self = Self(18);
102    #[doc(alias = "UIBarButtonSystemItemRewind")]
103    pub const Rewind: Self = Self(19);
104    #[doc(alias = "UIBarButtonSystemItemFastForward")]
105    pub const FastForward: Self = Self(20);
106    #[doc(alias = "UIBarButtonSystemItemUndo")]
107    pub const Undo: Self = Self(21);
108    #[doc(alias = "UIBarButtonSystemItemRedo")]
109    pub const Redo: Self = Self(22);
110    #[doc(alias = "UIBarButtonSystemItemPageCurl")]
111    #[deprecated]
112    pub const PageCurl: Self = Self(23);
113    #[doc(alias = "UIBarButtonSystemItemClose")]
114    pub const Close: Self = Self(24);
115    #[doc(alias = "UIBarButtonSystemItemWritingTools")]
116    pub const WritingTools: Self = Self(25);
117}
118
119unsafe impl Encode for UIBarButtonSystemItem {
120    const ENCODING: Encoding = NSInteger::ENCODING;
121}
122
123unsafe impl RefEncode for UIBarButtonSystemItem {
124    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
125}
126
127extern_class!(
128    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uibarbuttonitem?language=objc)
129    #[unsafe(super(UIBarItem, NSObject))]
130    #[thread_kind = MainThreadOnly]
131    #[derive(Debug, PartialEq, Eq, Hash)]
132    #[cfg(feature = "UIBarItem")]
133    pub struct UIBarButtonItem;
134);
135
136#[cfg(feature = "UIBarItem")]
137extern_conformance!(
138    unsafe impl NSCoding for UIBarButtonItem {}
139);
140
141#[cfg(feature = "UIBarItem")]
142extern_conformance!(
143    unsafe impl NSObjectProtocol for UIBarButtonItem {}
144);
145
146#[cfg(all(feature = "UIAppearance", feature = "UIBarItem"))]
147extern_conformance!(
148    unsafe impl UIAppearance for UIBarButtonItem {}
149);
150
151#[cfg(feature = "UIBarItem")]
152impl UIBarButtonItem {
153    extern_methods!(
154        #[unsafe(method(init))]
155        #[unsafe(method_family = init)]
156        pub fn init(this: Allocated<Self>) -> Retained<Self>;
157
158        /// # Safety
159        ///
160        /// `coder` possibly has further requirements.
161        #[unsafe(method(initWithCoder:))]
162        #[unsafe(method_family = init)]
163        pub unsafe fn initWithCoder(
164            this: Allocated<Self>,
165            coder: &NSCoder,
166        ) -> Option<Retained<Self>>;
167
168        #[cfg(feature = "UIImage")]
169        /// # Safety
170        ///
171        /// - `target` should be of the correct type.
172        /// - `action` must be a valid selector.
173        #[unsafe(method(initWithImage:style:target:action:))]
174        #[unsafe(method_family = init)]
175        pub unsafe fn initWithImage_style_target_action(
176            this: Allocated<Self>,
177            image: Option<&UIImage>,
178            style: UIBarButtonItemStyle,
179            target: Option<&AnyObject>,
180            action: Option<Sel>,
181        ) -> Retained<Self>;
182
183        #[cfg(feature = "UIImage")]
184        /// # Safety
185        ///
186        /// - `target` should be of the correct type.
187        /// - `action` must be a valid selector.
188        #[unsafe(method(initWithImage:landscapeImagePhone:style:target:action:))]
189        #[unsafe(method_family = init)]
190        pub unsafe fn initWithImage_landscapeImagePhone_style_target_action(
191            this: Allocated<Self>,
192            image: Option<&UIImage>,
193            landscape_image_phone: Option<&UIImage>,
194            style: UIBarButtonItemStyle,
195            target: Option<&AnyObject>,
196            action: Option<Sel>,
197        ) -> Retained<Self>;
198
199        /// # Safety
200        ///
201        /// - `target` should be of the correct type.
202        /// - `action` must be a valid selector.
203        #[unsafe(method(initWithTitle:style:target:action:))]
204        #[unsafe(method_family = init)]
205        pub unsafe fn initWithTitle_style_target_action(
206            this: Allocated<Self>,
207            title: Option<&NSString>,
208            style: UIBarButtonItemStyle,
209            target: Option<&AnyObject>,
210            action: Option<Sel>,
211        ) -> Retained<Self>;
212
213        /// # Safety
214        ///
215        /// - `target` should be of the correct type.
216        /// - `action` must be a valid selector.
217        #[unsafe(method(initWithBarButtonSystemItem:target:action:))]
218        #[unsafe(method_family = init)]
219        pub unsafe fn initWithBarButtonSystemItem_target_action(
220            this: Allocated<Self>,
221            system_item: UIBarButtonSystemItem,
222            target: Option<&AnyObject>,
223            action: Option<Sel>,
224        ) -> Retained<Self>;
225
226        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
227        #[unsafe(method(initWithCustomView:))]
228        #[unsafe(method_family = init)]
229        pub fn initWithCustomView(this: Allocated<Self>, custom_view: &UIView) -> Retained<Self>;
230
231        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
232        /// Creates a bar button item for the given systemItem. The primaryAction is copied, and its title
233        /// &
234        /// image are ignored.
235        #[unsafe(method(initWithBarButtonSystemItem:primaryAction:))]
236        #[unsafe(method_family = init)]
237        pub fn initWithBarButtonSystemItem_primaryAction(
238            this: Allocated<Self>,
239            system_item: UIBarButtonSystemItem,
240            primary_action: Option<&UIAction>,
241        ) -> Retained<Self>;
242
243        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
244        /// Creates a plain-style bar button item from the properties of primaryAction. primaryAction is copied.
245        #[unsafe(method(initWithPrimaryAction:))]
246        #[unsafe(method_family = init)]
247        pub fn initWithPrimaryAction(
248            this: Allocated<Self>,
249            primary_action: Option<&UIAction>,
250        ) -> Retained<Self>;
251
252        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
253        /// Creates a bar button item for the given systemItem. The constructed item will present the menu immediately when touched.
254        #[unsafe(method(initWithBarButtonSystemItem:menu:))]
255        #[unsafe(method_family = init)]
256        pub fn initWithBarButtonSystemItem_menu(
257            this: Allocated<Self>,
258            system_item: UIBarButtonSystemItem,
259            menu: Option<&UIMenu>,
260        ) -> Retained<Self>;
261
262        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
263        /// Creates a plain-style bar button item with the given title. The constructed item will present the menu immediately when touched.
264        #[unsafe(method(initWithTitle:menu:))]
265        #[unsafe(method_family = init)]
266        pub fn initWithTitle_menu(
267            this: Allocated<Self>,
268            title: Option<&NSString>,
269            menu: Option<&UIMenu>,
270        ) -> Retained<Self>;
271
272        #[cfg(all(feature = "UIImage", feature = "UIMenu", feature = "UIMenuElement"))]
273        /// Creates a plain-style bar button item with the given image. The constructed item will present the menu immediately when touched.
274        #[unsafe(method(initWithImage:menu:))]
275        #[unsafe(method_family = init)]
276        pub fn initWithImage_menu(
277            this: Allocated<Self>,
278            image: Option<&UIImage>,
279            menu: Option<&UIMenu>,
280        ) -> Retained<Self>;
281
282        #[cfg(all(feature = "UIAction", feature = "UIMenu", feature = "UIMenuElement"))]
283        /// Creates a plain-style bar button item from the properties of primaryAction. primaryAction is copied.
284        #[unsafe(method(initWithPrimaryAction:menu:))]
285        #[unsafe(method_family = init)]
286        pub fn initWithPrimaryAction_menu(
287            this: Allocated<Self>,
288            primary_action: Option<&UIAction>,
289            menu: Option<&UIMenu>,
290        ) -> Retained<Self>;
291
292        #[cfg(all(feature = "UIAction", feature = "UIMenu", feature = "UIMenuElement"))]
293        /// Creates a bar button item for the given systemItem. The primaryAction is copied, and its title
294        /// &
295        /// image are ignored.
296        #[unsafe(method(initWithBarButtonSystemItem:primaryAction:menu:))]
297        #[unsafe(method_family = init)]
298        pub fn initWithBarButtonSystemItem_primaryAction_menu(
299            this: Allocated<Self>,
300            system_item: UIBarButtonSystemItem,
301            primary_action: Option<&UIAction>,
302            menu: Option<&UIMenu>,
303        ) -> Retained<Self>;
304
305        #[cfg(all(feature = "UIImage", feature = "UIMenu", feature = "UIMenuElement"))]
306        /// Creates a plain-style bar button item with the given title and image.
307        ///
308        /// # Safety
309        ///
310        /// - `target` should be of the correct type.
311        /// - `action` must be a valid selector.
312        #[unsafe(method(initWithTitle:image:target:action:menu:))]
313        #[unsafe(method_family = init)]
314        pub unsafe fn initWithTitle_image_target_action_menu(
315            this: Allocated<Self>,
316            title: Option<&NSString>,
317            image: Option<&UIImage>,
318            target: Option<&AnyObject>,
319            action: Option<Sel>,
320            menu: Option<&UIMenu>,
321        ) -> Retained<Self>;
322
323        #[cfg(feature = "objc2-core-foundation")]
324        /// Construct a new fixed space item with the given width.
325        #[unsafe(method(fixedSpaceItemOfWidth:))]
326        #[unsafe(method_family = none)]
327        pub fn fixedSpaceItemOfWidth(width: CGFloat, mtm: MainThreadMarker) -> Retained<Self>;
328
329        /// Construct a new flexible space item.
330        #[unsafe(method(flexibleSpaceItem))]
331        #[unsafe(method_family = none)]
332        pub fn flexibleSpaceItem(mtm: MainThreadMarker) -> Retained<Self>;
333
334        /// Creates a new fixed space item of zero width.
335        ///
336        /// A fixed space of 0 width separates the shared background used
337        /// in navigation bars and toolbars to visually group items.
338        #[unsafe(method(fixedSpaceItem))]
339        #[unsafe(method_family = none)]
340        pub fn fixedSpaceItem(mtm: MainThreadMarker) -> Retained<Self>;
341
342        #[unsafe(method(style))]
343        #[unsafe(method_family = none)]
344        pub fn style(&self) -> UIBarButtonItemStyle;
345
346        /// Setter for [`style`][Self::style].
347        #[unsafe(method(setStyle:))]
348        #[unsafe(method_family = none)]
349        pub fn setStyle(&self, style: UIBarButtonItemStyle);
350
351        #[cfg(feature = "objc2-core-foundation")]
352        #[unsafe(method(width))]
353        #[unsafe(method_family = none)]
354        pub fn width(&self) -> CGFloat;
355
356        #[cfg(feature = "objc2-core-foundation")]
357        /// Setter for [`width`][Self::width].
358        #[unsafe(method(setWidth:))]
359        #[unsafe(method_family = none)]
360        pub fn setWidth(&self, width: CGFloat);
361
362        #[unsafe(method(possibleTitles))]
363        #[unsafe(method_family = none)]
364        pub fn possibleTitles(&self) -> Option<Retained<NSSet<NSString>>>;
365
366        /// Setter for [`possibleTitles`][Self::possibleTitles].
367        ///
368        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
369        #[unsafe(method(setPossibleTitles:))]
370        #[unsafe(method_family = none)]
371        pub fn setPossibleTitles(&self, possible_titles: Option<&NSSet<NSString>>);
372
373        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
374        #[unsafe(method(customView))]
375        #[unsafe(method_family = none)]
376        pub fn customView(&self) -> Option<Retained<UIView>>;
377
378        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
379        /// Setter for [`customView`][Self::customView].
380        #[unsafe(method(setCustomView:))]
381        #[unsafe(method_family = none)]
382        pub fn setCustomView(&self, custom_view: Option<&UIView>);
383
384        /// # Safety
385        ///
386        /// You must ensure this is still alive.
387        #[unsafe(method(action))]
388        #[unsafe(method_family = none)]
389        pub unsafe fn action(&self) -> Option<Sel>;
390
391        /// Setter for [`action`][Self::action].
392        ///
393        /// # Safety
394        ///
395        /// - `action` must be a valid selector.
396        /// - This is unretained, you must ensure the object is kept alive while in use.
397        #[unsafe(method(setAction:))]
398        #[unsafe(method_family = none)]
399        pub unsafe fn setAction(&self, action: Option<Sel>);
400
401        #[unsafe(method(target))]
402        #[unsafe(method_family = none)]
403        pub fn target(&self) -> Option<Retained<AnyObject>>;
404
405        /// Setter for [`target`][Self::target].
406        ///
407        /// This is a [weak property][objc2::topics::weak_property].
408        ///
409        /// # Safety
410        ///
411        /// `target` should be of the correct type.
412        #[unsafe(method(setTarget:))]
413        #[unsafe(method_family = none)]
414        pub unsafe fn setTarget(&self, target: Option<&AnyObject>);
415
416        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
417        /// Set the primaryAction on this item, updating the title
418        /// &
419        /// image of the item if appropriate (primaryAction's title is non-nil for the title update, primaryAction's image is non-nil for the image update, and if this is not a system item). When primaryAction is non-nil, the target
420        /// &
421        /// action properties are ignored. If primaryAction is set to nil, the title
422        /// &
423        /// image properties are left unchanged.
424        #[unsafe(method(primaryAction))]
425        #[unsafe(method_family = none)]
426        pub fn primaryAction(&self) -> Option<Retained<UIAction>>;
427
428        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
429        /// Setter for [`primaryAction`][Self::primaryAction].
430        ///
431        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
432        #[unsafe(method(setPrimaryAction:))]
433        #[unsafe(method_family = none)]
434        pub fn setPrimaryAction(&self, primary_action: Option<&UIAction>);
435
436        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
437        /// When non-nil the menu is presented, the gesture used to trigger the menu is based on if the bar button item would normally trigger an action when tapped.
438        #[unsafe(method(menu))]
439        #[unsafe(method_family = none)]
440        pub fn menu(&self) -> Option<Retained<UIMenu>>;
441
442        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
443        /// Setter for [`menu`][Self::menu].
444        ///
445        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
446        #[unsafe(method(setMenu:))]
447        #[unsafe(method_family = none)]
448        pub fn setMenu(&self, menu: Option<&UIMenu>);
449
450        #[cfg(feature = "UIContextMenuConfiguration")]
451        /// Preferred menu element ordering strategy for menus displayed by this button.
452        #[unsafe(method(preferredMenuElementOrder))]
453        #[unsafe(method_family = none)]
454        pub fn preferredMenuElementOrder(&self) -> UIContextMenuConfigurationElementOrder;
455
456        #[cfg(feature = "UIContextMenuConfiguration")]
457        /// Setter for [`preferredMenuElementOrder`][Self::preferredMenuElementOrder].
458        #[unsafe(method(setPreferredMenuElementOrder:))]
459        #[unsafe(method_family = none)]
460        pub fn setPreferredMenuElementOrder(
461            &self,
462            preferred_menu_element_order: UIContextMenuConfigurationElementOrder,
463        );
464
465        /// Indicates if the button changes selection as its primary action.
466        /// This shows the menu as options for selection if a menu is populated and no action when tapped is enabled.
467        /// If no menu is provided and no action is enabled when tapped, the item is toggled on and off for the primary action.
468        #[unsafe(method(changesSelectionAsPrimaryAction))]
469        #[unsafe(method_family = none)]
470        pub fn changesSelectionAsPrimaryAction(&self) -> bool;
471
472        /// Setter for [`changesSelectionAsPrimaryAction`][Self::changesSelectionAsPrimaryAction].
473        #[unsafe(method(setChangesSelectionAsPrimaryAction:))]
474        #[unsafe(method_family = none)]
475        pub fn setChangesSelectionAsPrimaryAction(&self, changes_selection_as_primary_action: bool);
476
477        #[unsafe(method(isSelected))]
478        #[unsafe(method_family = none)]
479        pub fn isSelected(&self) -> bool;
480
481        /// Setter for [`isSelected`][Self::isSelected].
482        #[unsafe(method(setSelected:))]
483        #[unsafe(method_family = none)]
484        pub fn setSelected(&self, selected: bool);
485
486        /// If the item should be hidden from display.
487        #[unsafe(method(isHidden))]
488        #[unsafe(method_family = none)]
489        pub fn isHidden(&self) -> bool;
490
491        /// Setter for [`isHidden`][Self::isHidden].
492        #[unsafe(method(setHidden:))]
493        #[unsafe(method_family = none)]
494        pub fn setHidden(&self, hidden: bool);
495
496        /// Whether or not symbol animations are enabled for this bar button item.
497        #[unsafe(method(isSymbolAnimationEnabled))]
498        #[unsafe(method_family = none)]
499        pub fn isSymbolAnimationEnabled(&self) -> bool;
500
501        /// Setter for [`isSymbolAnimationEnabled`][Self::isSymbolAnimationEnabled].
502        #[unsafe(method(setSymbolAnimationEnabled:))]
503        #[unsafe(method_family = none)]
504        pub fn setSymbolAnimationEnabled(&self, symbol_animation_enabled: bool);
505
506        #[cfg(feature = "UIMenuElement")]
507        /// A UIMenuElement that should substitute for the UIBarButtonItem when displayed in a menu.
508        #[unsafe(method(menuRepresentation))]
509        #[unsafe(method_family = none)]
510        pub fn menuRepresentation(&self) -> Option<Retained<UIMenuElement>>;
511
512        #[cfg(feature = "UIMenuElement")]
513        /// Setter for [`menuRepresentation`][Self::menuRepresentation].
514        ///
515        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
516        #[unsafe(method(setMenuRepresentation:))]
517        #[unsafe(method_family = none)]
518        pub fn setMenuRepresentation(&self, menu_representation: Option<&UIMenuElement>);
519
520        /// A boolean value indicating whether the background this item may share with other items in the bar
521        /// should be hidden.
522        ///
523        /// Set this property to `YES` to prevent the standard shared background (typically using the Glass effect)
524        /// from being drawn behind this bar button item.
525        ///
526        /// This item will not be visually grouped with any other items,
527        /// without the standard shared background.
528        /// This property is ignored if the item is in a `UIBarButtonItemGroup` with more than one item.
529        /// The default value is `NO`.
530        #[unsafe(method(hidesSharedBackground))]
531        #[unsafe(method_family = none)]
532        pub fn hidesSharedBackground(&self) -> bool;
533
534        /// Setter for [`hidesSharedBackground`][Self::hidesSharedBackground].
535        #[unsafe(method(setHidesSharedBackground:))]
536        #[unsafe(method_family = none)]
537        pub fn setHidesSharedBackground(&self, hides_shared_background: bool);
538
539        /// A boolean value indicating whether this bar button item can share a background with other items
540        /// in a navigation bar or a toolbar.
541        ///
542        /// When `NO`, This item will not be visually grouped with any other items.
543        ///
544        /// This property is ignored if the item is in a `UIBarButtonItemGroup` with more than one item.
545        /// The default value is `YES`.
546        #[unsafe(method(sharesBackground))]
547        #[unsafe(method_family = none)]
548        pub fn sharesBackground(&self) -> bool;
549
550        /// Setter for [`sharesBackground`][Self::sharesBackground].
551        #[unsafe(method(setSharesBackground:))]
552        #[unsafe(method_family = none)]
553        pub fn setSharesBackground(&self, shares_background: bool);
554
555        /// An identifier used to match bar button items across transitions in a navigation bar or toolbar.
556        ///
557        /// When the set of bar button items in a navigation bar or toolbar changes (for example, when pushing
558        /// or popping view controllers), UIKit automatically animates the transition between the different sets
559        /// of items. By default, UIKit uses heuristics based on item position and content to determine which items
560        /// should be matched for these transitions.
561        ///
562        /// Set this property with the same value on two different bar button items in different navigation item
563        /// configurations to indicate that they should be treated as the same item during transitions. This allows
564        /// for more natural animations when the visuals or function of an item changes across contexts.
565        ///
566        /// The default value is `nil`, which means UIKit will use its default heuristics for transitions.
567        #[unsafe(method(identifier))]
568        #[unsafe(method_family = none)]
569        pub fn identifier(&self) -> Option<Retained<NSString>>;
570
571        /// Setter for [`identifier`][Self::identifier].
572        ///
573        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
574        #[unsafe(method(setIdentifier:))]
575        #[unsafe(method_family = none)]
576        pub fn setIdentifier(&self, identifier: Option<&NSString>);
577
578        #[cfg(feature = "UIBarButtonItemGroup")]
579        /// Create a fixed group containing this bar button item. UIBarButtonItems may only be in a single UIBarButtonItemGroup at a time, adding a bar button item to a group removes it from any previous group.
580        #[unsafe(method(creatingFixedGroup))]
581        #[unsafe(method_family = none)]
582        pub fn creatingFixedGroup(&self) -> Retained<UIBarButtonItemGroup>;
583
584        #[cfg(feature = "UIBarButtonItemGroup")]
585        /// Create a movable group containing this bar button item. UIBarButtonItems may only be in a single UIBarButtonItemGroup at a time, adding a bar button item to a group removes it from any previous group.
586        #[unsafe(method(creatingMovableGroupWithCustomizationIdentifier:))]
587        #[unsafe(method_family = none)]
588        pub fn creatingMovableGroupWithCustomizationIdentifier(
589            &self,
590            customization_identifier: &NSString,
591        ) -> Retained<UIBarButtonItemGroup>;
592
593        #[cfg(feature = "UIBarButtonItemGroup")]
594        /// Create an optional group containing this bar button item. UIBarButtonItems may only be in a single UIBarButtonItemGroup at a time, adding a bar button item to a group removes it from any previous group.
595        #[unsafe(method(creatingOptionalGroupWithCustomizationIdentifier:inDefaultCustomization:))]
596        #[unsafe(method_family = none)]
597        pub fn creatingOptionalGroupWithCustomizationIdentifier_inDefaultCustomization(
598            &self,
599            customization_identifier: &NSString,
600            in_default_customization: bool,
601        ) -> Retained<UIBarButtonItemGroup>;
602
603        #[cfg(all(feature = "UIBarCommon", feature = "UIControl", feature = "UIImage"))]
604        #[unsafe(method(setBackgroundImage:forState:barMetrics:))]
605        #[unsafe(method_family = none)]
606        pub fn setBackgroundImage_forState_barMetrics(
607            &self,
608            background_image: Option<&UIImage>,
609            state: UIControlState,
610            bar_metrics: UIBarMetrics,
611        );
612
613        #[cfg(all(feature = "UIBarCommon", feature = "UIControl", feature = "UIImage"))]
614        #[unsafe(method(backgroundImageForState:barMetrics:))]
615        #[unsafe(method_family = none)]
616        pub fn backgroundImageForState_barMetrics(
617            &self,
618            state: UIControlState,
619            bar_metrics: UIBarMetrics,
620        ) -> Option<Retained<UIImage>>;
621
622        #[cfg(all(feature = "UIBarCommon", feature = "UIControl", feature = "UIImage"))]
623        #[unsafe(method(setBackgroundImage:forState:style:barMetrics:))]
624        #[unsafe(method_family = none)]
625        pub fn setBackgroundImage_forState_style_barMetrics(
626            &self,
627            background_image: Option<&UIImage>,
628            state: UIControlState,
629            style: UIBarButtonItemStyle,
630            bar_metrics: UIBarMetrics,
631        );
632
633        #[cfg(all(feature = "UIBarCommon", feature = "UIControl", feature = "UIImage"))]
634        #[unsafe(method(backgroundImageForState:style:barMetrics:))]
635        #[unsafe(method_family = none)]
636        pub fn backgroundImageForState_style_barMetrics(
637            &self,
638            state: UIControlState,
639            style: UIBarButtonItemStyle,
640            bar_metrics: UIBarMetrics,
641        ) -> Option<Retained<UIImage>>;
642
643        #[cfg(feature = "UIColor")]
644        #[unsafe(method(tintColor))]
645        #[unsafe(method_family = none)]
646        pub fn tintColor(&self) -> Option<Retained<UIColor>>;
647
648        #[cfg(feature = "UIColor")]
649        /// Setter for [`tintColor`][Self::tintColor].
650        #[unsafe(method(setTintColor:))]
651        #[unsafe(method_family = none)]
652        pub fn setTintColor(&self, tint_color: Option<&UIColor>);
653
654        #[cfg(all(feature = "UIBarCommon", feature = "objc2-core-foundation"))]
655        #[unsafe(method(setBackgroundVerticalPositionAdjustment:forBarMetrics:))]
656        #[unsafe(method_family = none)]
657        pub fn setBackgroundVerticalPositionAdjustment_forBarMetrics(
658            &self,
659            adjustment: CGFloat,
660            bar_metrics: UIBarMetrics,
661        );
662
663        #[cfg(all(feature = "UIBarCommon", feature = "objc2-core-foundation"))]
664        #[unsafe(method(backgroundVerticalPositionAdjustmentForBarMetrics:))]
665        #[unsafe(method_family = none)]
666        pub fn backgroundVerticalPositionAdjustmentForBarMetrics(
667            &self,
668            bar_metrics: UIBarMetrics,
669        ) -> CGFloat;
670
671        #[cfg(all(
672            feature = "UIBarCommon",
673            feature = "UIGeometry",
674            feature = "objc2-core-foundation"
675        ))]
676        #[unsafe(method(setTitlePositionAdjustment:forBarMetrics:))]
677        #[unsafe(method_family = none)]
678        pub fn setTitlePositionAdjustment_forBarMetrics(
679            &self,
680            adjustment: UIOffset,
681            bar_metrics: UIBarMetrics,
682        );
683
684        #[cfg(all(
685            feature = "UIBarCommon",
686            feature = "UIGeometry",
687            feature = "objc2-core-foundation"
688        ))]
689        #[unsafe(method(titlePositionAdjustmentForBarMetrics:))]
690        #[unsafe(method_family = none)]
691        pub fn titlePositionAdjustmentForBarMetrics(&self, bar_metrics: UIBarMetrics) -> UIOffset;
692
693        #[cfg(all(feature = "UIBarCommon", feature = "UIControl", feature = "UIImage"))]
694        #[unsafe(method(setBackButtonBackgroundImage:forState:barMetrics:))]
695        #[unsafe(method_family = none)]
696        pub fn setBackButtonBackgroundImage_forState_barMetrics(
697            &self,
698            background_image: Option<&UIImage>,
699            state: UIControlState,
700            bar_metrics: UIBarMetrics,
701        );
702
703        #[cfg(all(feature = "UIBarCommon", feature = "UIControl", feature = "UIImage"))]
704        #[unsafe(method(backButtonBackgroundImageForState:barMetrics:))]
705        #[unsafe(method_family = none)]
706        pub fn backButtonBackgroundImageForState_barMetrics(
707            &self,
708            state: UIControlState,
709            bar_metrics: UIBarMetrics,
710        ) -> Option<Retained<UIImage>>;
711
712        #[cfg(all(
713            feature = "UIBarCommon",
714            feature = "UIGeometry",
715            feature = "objc2-core-foundation"
716        ))]
717        #[unsafe(method(setBackButtonTitlePositionAdjustment:forBarMetrics:))]
718        #[unsafe(method_family = none)]
719        pub fn setBackButtonTitlePositionAdjustment_forBarMetrics(
720            &self,
721            adjustment: UIOffset,
722            bar_metrics: UIBarMetrics,
723        );
724
725        #[cfg(all(
726            feature = "UIBarCommon",
727            feature = "UIGeometry",
728            feature = "objc2-core-foundation"
729        ))]
730        #[unsafe(method(backButtonTitlePositionAdjustmentForBarMetrics:))]
731        #[unsafe(method_family = none)]
732        pub fn backButtonTitlePositionAdjustmentForBarMetrics(
733            &self,
734            bar_metrics: UIBarMetrics,
735        ) -> UIOffset;
736
737        #[cfg(all(feature = "UIBarCommon", feature = "objc2-core-foundation"))]
738        #[unsafe(method(setBackButtonBackgroundVerticalPositionAdjustment:forBarMetrics:))]
739        #[unsafe(method_family = none)]
740        pub fn setBackButtonBackgroundVerticalPositionAdjustment_forBarMetrics(
741            &self,
742            adjustment: CGFloat,
743            bar_metrics: UIBarMetrics,
744        );
745
746        #[cfg(all(feature = "UIBarCommon", feature = "objc2-core-foundation"))]
747        #[unsafe(method(backButtonBackgroundVerticalPositionAdjustmentForBarMetrics:))]
748        #[unsafe(method_family = none)]
749        pub fn backButtonBackgroundVerticalPositionAdjustmentForBarMetrics(
750            &self,
751            bar_metrics: UIBarMetrics,
752        ) -> CGFloat;
753    );
754}
755
756/// Methods declared on superclass `NSObject`.
757#[cfg(feature = "UIBarItem")]
758impl UIBarButtonItem {
759    extern_methods!(
760        #[unsafe(method(new))]
761        #[unsafe(method_family = new)]
762        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
763    );
764}
765
766/// SpringLoading.
767#[cfg(feature = "UIBarItem")]
768impl UIBarButtonItem {
769    extern_methods!();
770}
771
772#[cfg(all(feature = "UIBarItem", feature = "UISpringLoadedInteractionSupporting"))]
773extern_conformance!(
774    unsafe impl UISpringLoadedInteractionSupporting for UIBarButtonItem {}
775);
776
777#[cfg(feature = "UIBarItem")]
778impl UIBarButtonItem {
779    extern_methods!(
780        #[cfg(feature = "objc2-symbols")]
781        /// Adds a symbol effect to the bar button item with default options and animation.
782        /// Only a subset of symbol effects are supported; Appear and Disappear effects, for example, are unsupported, and will assert.
783        #[unsafe(method(addSymbolEffect:))]
784        #[unsafe(method_family = none)]
785        pub fn addSymbolEffect(&self, symbol_effect: &NSSymbolEffect);
786
787        #[cfg(feature = "objc2-symbols")]
788        /// Adds a symbol effect to the bar button item with specified options and default animation.
789        /// Only a subset of symbol effects are supported; Appear and Disappear effects, for example, are unsupported, and will assert.
790        #[unsafe(method(addSymbolEffect:options:))]
791        #[unsafe(method_family = none)]
792        pub fn addSymbolEffect_options(
793            &self,
794            symbol_effect: &NSSymbolEffect,
795            options: &NSSymbolEffectOptions,
796        );
797
798        #[cfg(feature = "objc2-symbols")]
799        /// Adds a symbol effect to the bar button item with specified options and animation.
800        /// Only a subset of symbol effects are supported; Appear and Disappear effects, for example, are unsupported, and will assert.
801        #[unsafe(method(addSymbolEffect:options:animated:))]
802        #[unsafe(method_family = none)]
803        pub fn addSymbolEffect_options_animated(
804            &self,
805            symbol_effect: &NSSymbolEffect,
806            options: &NSSymbolEffectOptions,
807            animated: bool,
808        );
809
810        #[cfg(feature = "objc2-symbols")]
811        /// Removes from the bar button item the symbol effect matching the type of effect passed in, with default options and animation.
812        #[unsafe(method(removeSymbolEffectOfType:))]
813        #[unsafe(method_family = none)]
814        pub fn removeSymbolEffectOfType(&self, symbol_effect: &NSSymbolEffect);
815
816        #[cfg(feature = "objc2-symbols")]
817        /// Removes from the bar button item the symbol effect matching the type of effect passed in, with specified options and default animation.
818        #[unsafe(method(removeSymbolEffectOfType:options:))]
819        #[unsafe(method_family = none)]
820        pub fn removeSymbolEffectOfType_options(
821            &self,
822            symbol_effect: &NSSymbolEffect,
823            options: &NSSymbolEffectOptions,
824        );
825
826        #[cfg(feature = "objc2-symbols")]
827        /// Removes from the bar button item the symbol effect matching the type of effect passed in, with specified options and animation.
828        #[unsafe(method(removeSymbolEffectOfType:options:animated:))]
829        #[unsafe(method_family = none)]
830        pub fn removeSymbolEffectOfType_options_animated(
831            &self,
832            symbol_effect: &NSSymbolEffect,
833            options: &NSSymbolEffectOptions,
834            animated: bool,
835        );
836
837        /// Removes all symbol effects from the bar button item with default options and animation.
838        #[unsafe(method(removeAllSymbolEffects))]
839        #[unsafe(method_family = none)]
840        pub fn removeAllSymbolEffects(&self);
841
842        #[cfg(feature = "objc2-symbols")]
843        /// Removes all symbol effects from the bar button item with specified options and default animation.
844        #[unsafe(method(removeAllSymbolEffectsWithOptions:))]
845        #[unsafe(method_family = none)]
846        pub fn removeAllSymbolEffectsWithOptions(&self, options: &NSSymbolEffectOptions);
847
848        #[cfg(feature = "objc2-symbols")]
849        /// Removes all symbol effects from the bar button item with specified options and animation.
850        #[unsafe(method(removeAllSymbolEffectsWithOptions:animated:))]
851        #[unsafe(method_family = none)]
852        pub fn removeAllSymbolEffectsWithOptions_animated(
853            &self,
854            options: &NSSymbolEffectOptions,
855            animated: bool,
856        );
857
858        #[cfg(all(feature = "UIImage", feature = "objc2-symbols"))]
859        /// Sets the symbol image on the bar button item with a symbol content transition and default options.
860        /// Passing in a non-symbol image will result in undefined behavior.
861        #[unsafe(method(setSymbolImage:withContentTransition:))]
862        #[unsafe(method_family = none)]
863        pub fn setSymbolImage_withContentTransition(
864            &self,
865            symbol_image: &UIImage,
866            transition: &NSSymbolContentTransition,
867        );
868
869        #[cfg(all(feature = "UIImage", feature = "objc2-symbols"))]
870        /// Sets the symbol image on the bar button item with a symbol content transition and specified options.
871        /// Passing in a non-symbol image will result in undefined behavior.
872        #[unsafe(method(setSymbolImage:withContentTransition:options:))]
873        #[unsafe(method_family = none)]
874        pub fn setSymbolImage_withContentTransition_options(
875            &self,
876            symbol_image: &UIImage,
877            transition: &NSSymbolContentTransition,
878            options: &NSSymbolEffectOptions,
879        );
880    );
881}