objc2-ui-kit 0.3.2

Bindings to the UIKit framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-symbols")]
use objc2_symbols::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uibarbuttonitemstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIBarButtonItemStyle(pub NSInteger);
impl UIBarButtonItemStyle {
    #[doc(alias = "UIBarButtonItemStylePlain")]
    pub const Plain: Self = Self(0);
    /// A button item style for a prominent button.
    ///
    /// For example, use this for a button that completes or finalizes some task.
    /// Buttons with this style will not be visually grouped with other items
    /// in a navigation bar or toolbar, and will also have other styling changes
    /// appropriate to their context to indicate their prominence.
    #[doc(alias = "UIBarButtonItemStyleProminent")]
    pub const Prominent: Self = Self(2);
    /// A button item style for a prominent button.
    ///
    /// For example, use this for a button that completes or finalizes some task.
    /// Buttons with this style will not be visually grouped with other items
    /// in a navigation bar or toolbar, and will also have other styling changes
    /// appropriate to their context to indicate their prominence.
    #[doc(alias = "UIBarButtonItemStyleBordered")]
    #[deprecated]
    pub const Bordered: Self = Self(1);
    /// A button item style for a prominent button.
    ///
    /// For example, use this for a button that completes or finalizes some task.
    /// Buttons with this style will not be visually grouped with other items
    /// in a navigation bar or toolbar, and will also have other styling changes
    /// appropriate to their context to indicate their prominence.
    #[doc(alias = "UIBarButtonItemStyleDone")]
    #[deprecated]
    pub const Done: Self = Self(UIBarButtonItemStyle::Prominent.0);
}

unsafe impl Encode for UIBarButtonItemStyle {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIBarButtonItemStyle {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uibarbuttonsystemitem?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIBarButtonSystemItem(pub NSInteger);
impl UIBarButtonSystemItem {
    #[doc(alias = "UIBarButtonSystemItemDone")]
    pub const Done: Self = Self(0);
    #[doc(alias = "UIBarButtonSystemItemCancel")]
    pub const Cancel: Self = Self(1);
    #[doc(alias = "UIBarButtonSystemItemEdit")]
    pub const Edit: Self = Self(2);
    #[doc(alias = "UIBarButtonSystemItemSave")]
    pub const Save: Self = Self(3);
    #[doc(alias = "UIBarButtonSystemItemAdd")]
    pub const Add: Self = Self(4);
    #[doc(alias = "UIBarButtonSystemItemFlexibleSpace")]
    pub const FlexibleSpace: Self = Self(5);
    #[doc(alias = "UIBarButtonSystemItemFixedSpace")]
    pub const FixedSpace: Self = Self(6);
    #[doc(alias = "UIBarButtonSystemItemCompose")]
    pub const Compose: Self = Self(7);
    #[doc(alias = "UIBarButtonSystemItemReply")]
    pub const Reply: Self = Self(8);
    #[doc(alias = "UIBarButtonSystemItemAction")]
    pub const Action: Self = Self(9);
    #[doc(alias = "UIBarButtonSystemItemOrganize")]
    pub const Organize: Self = Self(10);
    #[doc(alias = "UIBarButtonSystemItemBookmarks")]
    pub const Bookmarks: Self = Self(11);
    #[doc(alias = "UIBarButtonSystemItemSearch")]
    pub const Search: Self = Self(12);
    #[doc(alias = "UIBarButtonSystemItemRefresh")]
    pub const Refresh: Self = Self(13);
    #[doc(alias = "UIBarButtonSystemItemStop")]
    pub const Stop: Self = Self(14);
    #[doc(alias = "UIBarButtonSystemItemCamera")]
    pub const Camera: Self = Self(15);
    #[doc(alias = "UIBarButtonSystemItemTrash")]
    pub const Trash: Self = Self(16);
    #[doc(alias = "UIBarButtonSystemItemPlay")]
    pub const Play: Self = Self(17);
    #[doc(alias = "UIBarButtonSystemItemPause")]
    pub const Pause: Self = Self(18);
    #[doc(alias = "UIBarButtonSystemItemRewind")]
    pub const Rewind: Self = Self(19);
    #[doc(alias = "UIBarButtonSystemItemFastForward")]
    pub const FastForward: Self = Self(20);
    #[doc(alias = "UIBarButtonSystemItemUndo")]
    pub const Undo: Self = Self(21);
    #[doc(alias = "UIBarButtonSystemItemRedo")]
    pub const Redo: Self = Self(22);
    #[doc(alias = "UIBarButtonSystemItemPageCurl")]
    #[deprecated]
    pub const PageCurl: Self = Self(23);
    #[doc(alias = "UIBarButtonSystemItemClose")]
    pub const Close: Self = Self(24);
    #[doc(alias = "UIBarButtonSystemItemWritingTools")]
    pub const WritingTools: Self = Self(25);
}

unsafe impl Encode for UIBarButtonSystemItem {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIBarButtonSystemItem {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uibarbuttonitem?language=objc)
    #[unsafe(super(UIBarItem, NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "UIBarItem")]
    pub struct UIBarButtonItem;
);

#[cfg(feature = "UIBarItem")]
extern_conformance!(
    unsafe impl NSCoding for UIBarButtonItem {}
);

#[cfg(feature = "UIBarItem")]
extern_conformance!(
    unsafe impl NSObjectProtocol for UIBarButtonItem {}
);

#[cfg(all(feature = "UIAppearance", feature = "UIBarItem"))]
extern_conformance!(
    unsafe impl UIAppearance for UIBarButtonItem {}
);

#[cfg(feature = "UIBarItem")]
impl UIBarButtonItem {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;

        #[cfg(feature = "UIImage")]
        /// # Safety
        ///
        /// - `target` should be of the correct type.
        /// - `action` must be a valid selector.
        #[unsafe(method(initWithImage:style:target:action:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithImage_style_target_action(
            this: Allocated<Self>,
            image: Option<&UIImage>,
            style: UIBarButtonItemStyle,
            target: Option<&AnyObject>,
            action: Option<Sel>,
        ) -> Retained<Self>;

        #[cfg(feature = "UIImage")]
        /// # Safety
        ///
        /// - `target` should be of the correct type.
        /// - `action` must be a valid selector.
        #[unsafe(method(initWithImage:landscapeImagePhone:style:target:action:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithImage_landscapeImagePhone_style_target_action(
            this: Allocated<Self>,
            image: Option<&UIImage>,
            landscape_image_phone: Option<&UIImage>,
            style: UIBarButtonItemStyle,
            target: Option<&AnyObject>,
            action: Option<Sel>,
        ) -> Retained<Self>;

        /// # Safety
        ///
        /// - `target` should be of the correct type.
        /// - `action` must be a valid selector.
        #[unsafe(method(initWithTitle:style:target:action:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithTitle_style_target_action(
            this: Allocated<Self>,
            title: Option<&NSString>,
            style: UIBarButtonItemStyle,
            target: Option<&AnyObject>,
            action: Option<Sel>,
        ) -> Retained<Self>;

        /// # Safety
        ///
        /// - `target` should be of the correct type.
        /// - `action` must be a valid selector.
        #[unsafe(method(initWithBarButtonSystemItem:target:action:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithBarButtonSystemItem_target_action(
            this: Allocated<Self>,
            system_item: UIBarButtonSystemItem,
            target: Option<&AnyObject>,
            action: Option<Sel>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[unsafe(method(initWithCustomView:))]
        #[unsafe(method_family = init)]
        pub fn initWithCustomView(this: Allocated<Self>, custom_view: &UIView) -> Retained<Self>;

        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
        /// Creates a bar button item for the given systemItem. The primaryAction is copied, and its title
        /// &
        /// image are ignored.
        #[unsafe(method(initWithBarButtonSystemItem:primaryAction:))]
        #[unsafe(method_family = init)]
        pub fn initWithBarButtonSystemItem_primaryAction(
            this: Allocated<Self>,
            system_item: UIBarButtonSystemItem,
            primary_action: Option<&UIAction>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
        /// Creates a plain-style bar button item from the properties of primaryAction. primaryAction is copied.
        #[unsafe(method(initWithPrimaryAction:))]
        #[unsafe(method_family = init)]
        pub fn initWithPrimaryAction(
            this: Allocated<Self>,
            primary_action: Option<&UIAction>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
        /// Creates a bar button item for the given systemItem. The constructed item will present the menu immediately when touched.
        #[unsafe(method(initWithBarButtonSystemItem:menu:))]
        #[unsafe(method_family = init)]
        pub fn initWithBarButtonSystemItem_menu(
            this: Allocated<Self>,
            system_item: UIBarButtonSystemItem,
            menu: Option<&UIMenu>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
        /// Creates a plain-style bar button item with the given title. The constructed item will present the menu immediately when touched.
        #[unsafe(method(initWithTitle:menu:))]
        #[unsafe(method_family = init)]
        pub fn initWithTitle_menu(
            this: Allocated<Self>,
            title: Option<&NSString>,
            menu: Option<&UIMenu>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "UIImage", feature = "UIMenu", feature = "UIMenuElement"))]
        /// Creates a plain-style bar button item with the given image. The constructed item will present the menu immediately when touched.
        #[unsafe(method(initWithImage:menu:))]
        #[unsafe(method_family = init)]
        pub fn initWithImage_menu(
            this: Allocated<Self>,
            image: Option<&UIImage>,
            menu: Option<&UIMenu>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "UIAction", feature = "UIMenu", feature = "UIMenuElement"))]
        /// Creates a plain-style bar button item from the properties of primaryAction. primaryAction is copied.
        #[unsafe(method(initWithPrimaryAction:menu:))]
        #[unsafe(method_family = init)]
        pub fn initWithPrimaryAction_menu(
            this: Allocated<Self>,
            primary_action: Option<&UIAction>,
            menu: Option<&UIMenu>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "UIAction", feature = "UIMenu", feature = "UIMenuElement"))]
        /// Creates a bar button item for the given systemItem. The primaryAction is copied, and its title
        /// &
        /// image are ignored.
        #[unsafe(method(initWithBarButtonSystemItem:primaryAction:menu:))]
        #[unsafe(method_family = init)]
        pub fn initWithBarButtonSystemItem_primaryAction_menu(
            this: Allocated<Self>,
            system_item: UIBarButtonSystemItem,
            primary_action: Option<&UIAction>,
            menu: Option<&UIMenu>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "UIImage", feature = "UIMenu", feature = "UIMenuElement"))]
        /// Creates a plain-style bar button item with the given title and image.
        ///
        /// # Safety
        ///
        /// - `target` should be of the correct type.
        /// - `action` must be a valid selector.
        #[unsafe(method(initWithTitle:image:target:action:menu:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithTitle_image_target_action_menu(
            this: Allocated<Self>,
            title: Option<&NSString>,
            image: Option<&UIImage>,
            target: Option<&AnyObject>,
            action: Option<Sel>,
            menu: Option<&UIMenu>,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-core-foundation")]
        /// Construct a new fixed space item with the given width.
        #[unsafe(method(fixedSpaceItemOfWidth:))]
        #[unsafe(method_family = none)]
        pub fn fixedSpaceItemOfWidth(width: CGFloat, mtm: MainThreadMarker) -> Retained<Self>;

        /// Construct a new flexible space item.
        #[unsafe(method(flexibleSpaceItem))]
        #[unsafe(method_family = none)]
        pub fn flexibleSpaceItem(mtm: MainThreadMarker) -> Retained<Self>;

        /// Creates a new fixed space item of zero width.
        ///
        /// A fixed space of 0 width separates the shared background used
        /// in navigation bars and toolbars to visually group items.
        #[unsafe(method(fixedSpaceItem))]
        #[unsafe(method_family = none)]
        pub fn fixedSpaceItem(mtm: MainThreadMarker) -> Retained<Self>;

        #[unsafe(method(style))]
        #[unsafe(method_family = none)]
        pub fn style(&self) -> UIBarButtonItemStyle;

        /// Setter for [`style`][Self::style].
        #[unsafe(method(setStyle:))]
        #[unsafe(method_family = none)]
        pub fn setStyle(&self, style: UIBarButtonItemStyle);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(width))]
        #[unsafe(method_family = none)]
        pub fn width(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`width`][Self::width].
        #[unsafe(method(setWidth:))]
        #[unsafe(method_family = none)]
        pub fn setWidth(&self, width: CGFloat);

        #[unsafe(method(possibleTitles))]
        #[unsafe(method_family = none)]
        pub fn possibleTitles(&self) -> Option<Retained<NSSet<NSString>>>;

        /// Setter for [`possibleTitles`][Self::possibleTitles].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setPossibleTitles:))]
        #[unsafe(method_family = none)]
        pub fn setPossibleTitles(&self, possible_titles: Option<&NSSet<NSString>>);

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[unsafe(method(customView))]
        #[unsafe(method_family = none)]
        pub fn customView(&self) -> Option<Retained<UIView>>;

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        /// Setter for [`customView`][Self::customView].
        #[unsafe(method(setCustomView:))]
        #[unsafe(method_family = none)]
        pub fn setCustomView(&self, custom_view: Option<&UIView>);

        /// # Safety
        ///
        /// You must ensure this is still alive.
        #[unsafe(method(action))]
        #[unsafe(method_family = none)]
        pub unsafe fn action(&self) -> Option<Sel>;

        /// Setter for [`action`][Self::action].
        ///
        /// # Safety
        ///
        /// - `action` must be a valid selector.
        /// - This is unretained, you must ensure the object is kept alive while in use.
        #[unsafe(method(setAction:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAction(&self, action: Option<Sel>);

        #[unsafe(method(target))]
        #[unsafe(method_family = none)]
        pub fn target(&self) -> Option<Retained<AnyObject>>;

        /// Setter for [`target`][Self::target].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        ///
        /// # Safety
        ///
        /// `target` should be of the correct type.
        #[unsafe(method(setTarget:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTarget(&self, target: Option<&AnyObject>);

        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
        /// Set the primaryAction on this item, updating the title
        /// &
        /// 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
        /// &
        /// action properties are ignored. If primaryAction is set to nil, the title
        /// &
        /// image properties are left unchanged.
        #[unsafe(method(primaryAction))]
        #[unsafe(method_family = none)]
        pub fn primaryAction(&self) -> Option<Retained<UIAction>>;

        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
        /// Setter for [`primaryAction`][Self::primaryAction].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setPrimaryAction:))]
        #[unsafe(method_family = none)]
        pub fn setPrimaryAction(&self, primary_action: Option<&UIAction>);

        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
        /// 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.
        #[unsafe(method(menu))]
        #[unsafe(method_family = none)]
        pub fn menu(&self) -> Option<Retained<UIMenu>>;

        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
        /// Setter for [`menu`][Self::menu].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setMenu:))]
        #[unsafe(method_family = none)]
        pub fn setMenu(&self, menu: Option<&UIMenu>);

        #[cfg(feature = "UIContextMenuConfiguration")]
        /// Preferred menu element ordering strategy for menus displayed by this button.
        #[unsafe(method(preferredMenuElementOrder))]
        #[unsafe(method_family = none)]
        pub fn preferredMenuElementOrder(&self) -> UIContextMenuConfigurationElementOrder;

        #[cfg(feature = "UIContextMenuConfiguration")]
        /// Setter for [`preferredMenuElementOrder`][Self::preferredMenuElementOrder].
        #[unsafe(method(setPreferredMenuElementOrder:))]
        #[unsafe(method_family = none)]
        pub fn setPreferredMenuElementOrder(
            &self,
            preferred_menu_element_order: UIContextMenuConfigurationElementOrder,
        );

        /// Indicates if the button changes selection as its primary action.
        /// This shows the menu as options for selection if a menu is populated and no action when tapped is enabled.
        /// If no menu is provided and no action is enabled when tapped, the item is toggled on and off for the primary action.
        #[unsafe(method(changesSelectionAsPrimaryAction))]
        #[unsafe(method_family = none)]
        pub fn changesSelectionAsPrimaryAction(&self) -> bool;

        /// Setter for [`changesSelectionAsPrimaryAction`][Self::changesSelectionAsPrimaryAction].
        #[unsafe(method(setChangesSelectionAsPrimaryAction:))]
        #[unsafe(method_family = none)]
        pub fn setChangesSelectionAsPrimaryAction(&self, changes_selection_as_primary_action: bool);

        #[unsafe(method(isSelected))]
        #[unsafe(method_family = none)]
        pub fn isSelected(&self) -> bool;

        /// Setter for [`isSelected`][Self::isSelected].
        #[unsafe(method(setSelected:))]
        #[unsafe(method_family = none)]
        pub fn setSelected(&self, selected: bool);

        /// If the item should be hidden from display.
        #[unsafe(method(isHidden))]
        #[unsafe(method_family = none)]
        pub fn isHidden(&self) -> bool;

        /// Setter for [`isHidden`][Self::isHidden].
        #[unsafe(method(setHidden:))]
        #[unsafe(method_family = none)]
        pub fn setHidden(&self, hidden: bool);

        /// Whether or not symbol animations are enabled for this bar button item.
        #[unsafe(method(isSymbolAnimationEnabled))]
        #[unsafe(method_family = none)]
        pub fn isSymbolAnimationEnabled(&self) -> bool;

        /// Setter for [`isSymbolAnimationEnabled`][Self::isSymbolAnimationEnabled].
        #[unsafe(method(setSymbolAnimationEnabled:))]
        #[unsafe(method_family = none)]
        pub fn setSymbolAnimationEnabled(&self, symbol_animation_enabled: bool);

        #[cfg(feature = "UIMenuElement")]
        /// A UIMenuElement that should substitute for the UIBarButtonItem when displayed in a menu.
        #[unsafe(method(menuRepresentation))]
        #[unsafe(method_family = none)]
        pub fn menuRepresentation(&self) -> Option<Retained<UIMenuElement>>;

        #[cfg(feature = "UIMenuElement")]
        /// Setter for [`menuRepresentation`][Self::menuRepresentation].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setMenuRepresentation:))]
        #[unsafe(method_family = none)]
        pub fn setMenuRepresentation(&self, menu_representation: Option<&UIMenuElement>);

        /// A boolean value indicating whether the background this item may share with other items in the bar
        /// should be hidden.
        ///
        /// Set this property to `YES` to prevent the standard shared background (typically using the Glass effect)
        /// from being drawn behind this bar button item.
        ///
        /// This item will not be visually grouped with any other items,
        /// without the standard shared background.
        /// This property is ignored if the item is in a `UIBarButtonItemGroup` with more than one item.
        /// The default value is `NO`.
        #[unsafe(method(hidesSharedBackground))]
        #[unsafe(method_family = none)]
        pub fn hidesSharedBackground(&self) -> bool;

        /// Setter for [`hidesSharedBackground`][Self::hidesSharedBackground].
        #[unsafe(method(setHidesSharedBackground:))]
        #[unsafe(method_family = none)]
        pub fn setHidesSharedBackground(&self, hides_shared_background: bool);

        /// A boolean value indicating whether this bar button item can share a background with other items
        /// in a navigation bar or a toolbar.
        ///
        /// When `NO`, This item will not be visually grouped with any other items.
        ///
        /// This property is ignored if the item is in a `UIBarButtonItemGroup` with more than one item.
        /// The default value is `YES`.
        #[unsafe(method(sharesBackground))]
        #[unsafe(method_family = none)]
        pub fn sharesBackground(&self) -> bool;

        /// Setter for [`sharesBackground`][Self::sharesBackground].
        #[unsafe(method(setSharesBackground:))]
        #[unsafe(method_family = none)]
        pub fn setSharesBackground(&self, shares_background: bool);

        /// An identifier used to match bar button items across transitions in a navigation bar or toolbar.
        ///
        /// When the set of bar button items in a navigation bar or toolbar changes (for example, when pushing
        /// or popping view controllers), UIKit automatically animates the transition between the different sets
        /// of items. By default, UIKit uses heuristics based on item position and content to determine which items
        /// should be matched for these transitions.
        ///
        /// Set this property with the same value on two different bar button items in different navigation item
        /// configurations to indicate that they should be treated as the same item during transitions. This allows
        /// for more natural animations when the visuals or function of an item changes across contexts.
        ///
        /// The default value is `nil`, which means UIKit will use its default heuristics for transitions.
        #[unsafe(method(identifier))]
        #[unsafe(method_family = none)]
        pub fn identifier(&self) -> Option<Retained<NSString>>;

        /// Setter for [`identifier`][Self::identifier].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setIdentifier:))]
        #[unsafe(method_family = none)]
        pub fn setIdentifier(&self, identifier: Option<&NSString>);

        #[cfg(feature = "UIBarButtonItemGroup")]
        /// 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.
        #[unsafe(method(creatingFixedGroup))]
        #[unsafe(method_family = none)]
        pub fn creatingFixedGroup(&self) -> Retained<UIBarButtonItemGroup>;

        #[cfg(feature = "UIBarButtonItemGroup")]
        /// 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.
        #[unsafe(method(creatingMovableGroupWithCustomizationIdentifier:))]
        #[unsafe(method_family = none)]
        pub fn creatingMovableGroupWithCustomizationIdentifier(
            &self,
            customization_identifier: &NSString,
        ) -> Retained<UIBarButtonItemGroup>;

        #[cfg(feature = "UIBarButtonItemGroup")]
        /// 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.
        #[unsafe(method(creatingOptionalGroupWithCustomizationIdentifier:inDefaultCustomization:))]
        #[unsafe(method_family = none)]
        pub fn creatingOptionalGroupWithCustomizationIdentifier_inDefaultCustomization(
            &self,
            customization_identifier: &NSString,
            in_default_customization: bool,
        ) -> Retained<UIBarButtonItemGroup>;

        #[cfg(all(feature = "UIBarCommon", feature = "UIControl", feature = "UIImage"))]
        #[unsafe(method(setBackgroundImage:forState:barMetrics:))]
        #[unsafe(method_family = none)]
        pub fn setBackgroundImage_forState_barMetrics(
            &self,
            background_image: Option<&UIImage>,
            state: UIControlState,
            bar_metrics: UIBarMetrics,
        );

        #[cfg(all(feature = "UIBarCommon", feature = "UIControl", feature = "UIImage"))]
        #[unsafe(method(backgroundImageForState:barMetrics:))]
        #[unsafe(method_family = none)]
        pub fn backgroundImageForState_barMetrics(
            &self,
            state: UIControlState,
            bar_metrics: UIBarMetrics,
        ) -> Option<Retained<UIImage>>;

        #[cfg(all(feature = "UIBarCommon", feature = "UIControl", feature = "UIImage"))]
        #[unsafe(method(setBackgroundImage:forState:style:barMetrics:))]
        #[unsafe(method_family = none)]
        pub fn setBackgroundImage_forState_style_barMetrics(
            &self,
            background_image: Option<&UIImage>,
            state: UIControlState,
            style: UIBarButtonItemStyle,
            bar_metrics: UIBarMetrics,
        );

        #[cfg(all(feature = "UIBarCommon", feature = "UIControl", feature = "UIImage"))]
        #[unsafe(method(backgroundImageForState:style:barMetrics:))]
        #[unsafe(method_family = none)]
        pub fn backgroundImageForState_style_barMetrics(
            &self,
            state: UIControlState,
            style: UIBarButtonItemStyle,
            bar_metrics: UIBarMetrics,
        ) -> Option<Retained<UIImage>>;

        #[cfg(feature = "UIColor")]
        #[unsafe(method(tintColor))]
        #[unsafe(method_family = none)]
        pub fn tintColor(&self) -> Option<Retained<UIColor>>;

        #[cfg(feature = "UIColor")]
        /// Setter for [`tintColor`][Self::tintColor].
        #[unsafe(method(setTintColor:))]
        #[unsafe(method_family = none)]
        pub fn setTintColor(&self, tint_color: Option<&UIColor>);

        #[cfg(all(feature = "UIBarCommon", feature = "objc2-core-foundation"))]
        #[unsafe(method(setBackgroundVerticalPositionAdjustment:forBarMetrics:))]
        #[unsafe(method_family = none)]
        pub fn setBackgroundVerticalPositionAdjustment_forBarMetrics(
            &self,
            adjustment: CGFloat,
            bar_metrics: UIBarMetrics,
        );

        #[cfg(all(feature = "UIBarCommon", feature = "objc2-core-foundation"))]
        #[unsafe(method(backgroundVerticalPositionAdjustmentForBarMetrics:))]
        #[unsafe(method_family = none)]
        pub fn backgroundVerticalPositionAdjustmentForBarMetrics(
            &self,
            bar_metrics: UIBarMetrics,
        ) -> CGFloat;

        #[cfg(all(
            feature = "UIBarCommon",
            feature = "UIGeometry",
            feature = "objc2-core-foundation"
        ))]
        #[unsafe(method(setTitlePositionAdjustment:forBarMetrics:))]
        #[unsafe(method_family = none)]
        pub fn setTitlePositionAdjustment_forBarMetrics(
            &self,
            adjustment: UIOffset,
            bar_metrics: UIBarMetrics,
        );

        #[cfg(all(
            feature = "UIBarCommon",
            feature = "UIGeometry",
            feature = "objc2-core-foundation"
        ))]
        #[unsafe(method(titlePositionAdjustmentForBarMetrics:))]
        #[unsafe(method_family = none)]
        pub fn titlePositionAdjustmentForBarMetrics(&self, bar_metrics: UIBarMetrics) -> UIOffset;

        #[cfg(all(feature = "UIBarCommon", feature = "UIControl", feature = "UIImage"))]
        #[unsafe(method(setBackButtonBackgroundImage:forState:barMetrics:))]
        #[unsafe(method_family = none)]
        pub fn setBackButtonBackgroundImage_forState_barMetrics(
            &self,
            background_image: Option<&UIImage>,
            state: UIControlState,
            bar_metrics: UIBarMetrics,
        );

        #[cfg(all(feature = "UIBarCommon", feature = "UIControl", feature = "UIImage"))]
        #[unsafe(method(backButtonBackgroundImageForState:barMetrics:))]
        #[unsafe(method_family = none)]
        pub fn backButtonBackgroundImageForState_barMetrics(
            &self,
            state: UIControlState,
            bar_metrics: UIBarMetrics,
        ) -> Option<Retained<UIImage>>;

        #[cfg(all(
            feature = "UIBarCommon",
            feature = "UIGeometry",
            feature = "objc2-core-foundation"
        ))]
        #[unsafe(method(setBackButtonTitlePositionAdjustment:forBarMetrics:))]
        #[unsafe(method_family = none)]
        pub fn setBackButtonTitlePositionAdjustment_forBarMetrics(
            &self,
            adjustment: UIOffset,
            bar_metrics: UIBarMetrics,
        );

        #[cfg(all(
            feature = "UIBarCommon",
            feature = "UIGeometry",
            feature = "objc2-core-foundation"
        ))]
        #[unsafe(method(backButtonTitlePositionAdjustmentForBarMetrics:))]
        #[unsafe(method_family = none)]
        pub fn backButtonTitlePositionAdjustmentForBarMetrics(
            &self,
            bar_metrics: UIBarMetrics,
        ) -> UIOffset;

        #[cfg(all(feature = "UIBarCommon", feature = "objc2-core-foundation"))]
        #[unsafe(method(setBackButtonBackgroundVerticalPositionAdjustment:forBarMetrics:))]
        #[unsafe(method_family = none)]
        pub fn setBackButtonBackgroundVerticalPositionAdjustment_forBarMetrics(
            &self,
            adjustment: CGFloat,
            bar_metrics: UIBarMetrics,
        );

        #[cfg(all(feature = "UIBarCommon", feature = "objc2-core-foundation"))]
        #[unsafe(method(backButtonBackgroundVerticalPositionAdjustmentForBarMetrics:))]
        #[unsafe(method_family = none)]
        pub fn backButtonBackgroundVerticalPositionAdjustmentForBarMetrics(
            &self,
            bar_metrics: UIBarMetrics,
        ) -> CGFloat;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "UIBarItem")]
impl UIBarButtonItem {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

/// SpringLoading.
#[cfg(feature = "UIBarItem")]
impl UIBarButtonItem {
    extern_methods!();
}

#[cfg(all(feature = "UIBarItem", feature = "UISpringLoadedInteractionSupporting"))]
extern_conformance!(
    unsafe impl UISpringLoadedInteractionSupporting for UIBarButtonItem {}
);

#[cfg(feature = "UIBarItem")]
impl UIBarButtonItem {
    extern_methods!(
        #[cfg(feature = "objc2-symbols")]
        /// Adds a symbol effect to the bar button item with default options and animation.
        /// Only a subset of symbol effects are supported; Appear and Disappear effects, for example, are unsupported, and will assert.
        #[unsafe(method(addSymbolEffect:))]
        #[unsafe(method_family = none)]
        pub fn addSymbolEffect(&self, symbol_effect: &NSSymbolEffect);

        #[cfg(feature = "objc2-symbols")]
        /// Adds a symbol effect to the bar button item with specified options and default animation.
        /// Only a subset of symbol effects are supported; Appear and Disappear effects, for example, are unsupported, and will assert.
        #[unsafe(method(addSymbolEffect:options:))]
        #[unsafe(method_family = none)]
        pub fn addSymbolEffect_options(
            &self,
            symbol_effect: &NSSymbolEffect,
            options: &NSSymbolEffectOptions,
        );

        #[cfg(feature = "objc2-symbols")]
        /// Adds a symbol effect to the bar button item with specified options and animation.
        /// Only a subset of symbol effects are supported; Appear and Disappear effects, for example, are unsupported, and will assert.
        #[unsafe(method(addSymbolEffect:options:animated:))]
        #[unsafe(method_family = none)]
        pub fn addSymbolEffect_options_animated(
            &self,
            symbol_effect: &NSSymbolEffect,
            options: &NSSymbolEffectOptions,
            animated: bool,
        );

        #[cfg(feature = "objc2-symbols")]
        /// Removes from the bar button item the symbol effect matching the type of effect passed in, with default options and animation.
        #[unsafe(method(removeSymbolEffectOfType:))]
        #[unsafe(method_family = none)]
        pub fn removeSymbolEffectOfType(&self, symbol_effect: &NSSymbolEffect);

        #[cfg(feature = "objc2-symbols")]
        /// Removes from the bar button item the symbol effect matching the type of effect passed in, with specified options and default animation.
        #[unsafe(method(removeSymbolEffectOfType:options:))]
        #[unsafe(method_family = none)]
        pub fn removeSymbolEffectOfType_options(
            &self,
            symbol_effect: &NSSymbolEffect,
            options: &NSSymbolEffectOptions,
        );

        #[cfg(feature = "objc2-symbols")]
        /// Removes from the bar button item the symbol effect matching the type of effect passed in, with specified options and animation.
        #[unsafe(method(removeSymbolEffectOfType:options:animated:))]
        #[unsafe(method_family = none)]
        pub fn removeSymbolEffectOfType_options_animated(
            &self,
            symbol_effect: &NSSymbolEffect,
            options: &NSSymbolEffectOptions,
            animated: bool,
        );

        /// Removes all symbol effects from the bar button item with default options and animation.
        #[unsafe(method(removeAllSymbolEffects))]
        #[unsafe(method_family = none)]
        pub fn removeAllSymbolEffects(&self);

        #[cfg(feature = "objc2-symbols")]
        /// Removes all symbol effects from the bar button item with specified options and default animation.
        #[unsafe(method(removeAllSymbolEffectsWithOptions:))]
        #[unsafe(method_family = none)]
        pub fn removeAllSymbolEffectsWithOptions(&self, options: &NSSymbolEffectOptions);

        #[cfg(feature = "objc2-symbols")]
        /// Removes all symbol effects from the bar button item with specified options and animation.
        #[unsafe(method(removeAllSymbolEffectsWithOptions:animated:))]
        #[unsafe(method_family = none)]
        pub fn removeAllSymbolEffectsWithOptions_animated(
            &self,
            options: &NSSymbolEffectOptions,
            animated: bool,
        );

        #[cfg(all(feature = "UIImage", feature = "objc2-symbols"))]
        /// Sets the symbol image on the bar button item with a symbol content transition and default options.
        /// Passing in a non-symbol image will result in undefined behavior.
        #[unsafe(method(setSymbolImage:withContentTransition:))]
        #[unsafe(method_family = none)]
        pub fn setSymbolImage_withContentTransition(
            &self,
            symbol_image: &UIImage,
            transition: &NSSymbolContentTransition,
        );

        #[cfg(all(feature = "UIImage", feature = "objc2-symbols"))]
        /// Sets the symbol image on the bar button item with a symbol content transition and specified options.
        /// Passing in a non-symbol image will result in undefined behavior.
        #[unsafe(method(setSymbolImage:withContentTransition:options:))]
        #[unsafe(method_family = none)]
        pub fn setSymbolImage_withContentTransition_options(
            &self,
            symbol_image: &UIImage,
            transition: &NSSymbolContentTransition,
            options: &NSSymbolEffectOptions,
        );
    );
}