objc2_ui_kit/generated/
UINavigationBar.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/uinavigationbarnstoolbarsection?language=objc)
16// NS_ENUM
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct UINavigationBarNSToolbarSection(pub NSInteger);
20impl UINavigationBarNSToolbarSection {
21    #[doc(alias = "UINavigationBarNSToolbarSectionNone")]
22    pub const None: Self = Self(0);
23    #[doc(alias = "UINavigationBarNSToolbarSectionSidebar")]
24    pub const Sidebar: Self = Self(1);
25    #[doc(alias = "UINavigationBarNSToolbarSectionSupplementary")]
26    pub const Supplementary: Self = Self(2);
27    #[doc(alias = "UINavigationBarNSToolbarSectionContent")]
28    pub const Content: Self = Self(3);
29}
30
31unsafe impl Encode for UINavigationBarNSToolbarSection {
32    const ENCODING: Encoding = NSInteger::ENCODING;
33}
34
35unsafe impl RefEncode for UINavigationBarNSToolbarSection {
36    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
37}
38
39extern_class!(
40    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uinavigationbar?language=objc)
41    #[unsafe(super(UIView, UIResponder, NSObject))]
42    #[thread_kind = MainThreadOnly]
43    #[derive(Debug, PartialEq, Eq, Hash)]
44    #[cfg(all(feature = "UIResponder", feature = "UIView"))]
45    pub struct UINavigationBar;
46);
47
48#[cfg(all(
49    feature = "UIResponder",
50    feature = "UIView",
51    feature = "objc2-quartz-core"
52))]
53#[cfg(not(target_os = "watchos"))]
54extern_conformance!(
55    unsafe impl CALayerDelegate for UINavigationBar {}
56);
57
58#[cfg(all(feature = "UIResponder", feature = "UIView"))]
59extern_conformance!(
60    unsafe impl NSCoding for UINavigationBar {}
61);
62
63#[cfg(all(feature = "UIResponder", feature = "UIView"))]
64extern_conformance!(
65    unsafe impl NSObjectProtocol for UINavigationBar {}
66);
67
68#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
69extern_conformance!(
70    unsafe impl UIAppearance for UINavigationBar {}
71);
72
73#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
74extern_conformance!(
75    unsafe impl UIAppearanceContainer for UINavigationBar {}
76);
77
78#[cfg(all(feature = "UIBarCommon", feature = "UIResponder", feature = "UIView"))]
79extern_conformance!(
80    unsafe impl UIBarPositioning for UINavigationBar {}
81);
82
83#[cfg(all(feature = "UIResponder", feature = "UIView"))]
84extern_conformance!(
85    unsafe impl UICoordinateSpace for UINavigationBar {}
86);
87
88#[cfg(all(
89    feature = "UIDynamicBehavior",
90    feature = "UIResponder",
91    feature = "UIView"
92))]
93extern_conformance!(
94    unsafe impl UIDynamicItem for UINavigationBar {}
95);
96
97#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
98extern_conformance!(
99    unsafe impl UIFocusEnvironment for UINavigationBar {}
100);
101
102#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
103extern_conformance!(
104    unsafe impl UIFocusItem for UINavigationBar {}
105);
106
107#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
108extern_conformance!(
109    unsafe impl UIFocusItemContainer for UINavigationBar {}
110);
111
112#[cfg(all(feature = "UIResponder", feature = "UIView"))]
113extern_conformance!(
114    unsafe impl UIResponderStandardEditActions for UINavigationBar {}
115);
116
117#[cfg(all(
118    feature = "UIResponder",
119    feature = "UITraitCollection",
120    feature = "UIView"
121))]
122extern_conformance!(
123    unsafe impl UITraitEnvironment for UINavigationBar {}
124);
125
126#[cfg(all(feature = "UIResponder", feature = "UIView"))]
127impl UINavigationBar {
128    extern_methods!(
129        #[cfg(feature = "UIInterface")]
130        #[unsafe(method(barStyle))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn barStyle(&self) -> UIBarStyle;
133
134        #[cfg(feature = "UIInterface")]
135        /// Setter for [`barStyle`][Self::barStyle].
136        #[unsafe(method(setBarStyle:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn setBarStyle(&self, bar_style: UIBarStyle);
139
140        #[cfg(feature = "UIBarCommon")]
141        #[unsafe(method(delegate))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn delegate(
144            &self,
145        ) -> Option<Retained<ProtocolObject<dyn UINavigationBarDelegate>>>;
146
147        #[cfg(feature = "UIBarCommon")]
148        /// This is a [weak property][objc2::topics::weak_property].
149        /// Setter for [`delegate`][Self::delegate].
150        #[unsafe(method(setDelegate:))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn setDelegate(
153            &self,
154            delegate: Option<&ProtocolObject<dyn UINavigationBarDelegate>>,
155        );
156
157        #[unsafe(method(isTranslucent))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn isTranslucent(&self) -> bool;
160
161        /// Setter for [`isTranslucent`][Self::isTranslucent].
162        #[unsafe(method(setTranslucent:))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn setTranslucent(&self, translucent: bool);
165
166        #[cfg(feature = "UINavigationItem")]
167        #[unsafe(method(pushNavigationItem:animated:))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn pushNavigationItem_animated(&self, item: &UINavigationItem, animated: bool);
170
171        #[cfg(feature = "UINavigationItem")]
172        #[unsafe(method(popNavigationItemAnimated:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn popNavigationItemAnimated(
175            &self,
176            animated: bool,
177        ) -> Option<Retained<UINavigationItem>>;
178
179        #[cfg(feature = "UINavigationItem")]
180        #[unsafe(method(topItem))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn topItem(&self) -> Option<Retained<UINavigationItem>>;
183
184        #[cfg(feature = "UINavigationItem")]
185        #[unsafe(method(backItem))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn backItem(&self) -> Option<Retained<UINavigationItem>>;
188
189        #[cfg(feature = "UINavigationItem")]
190        #[unsafe(method(items))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn items(&self) -> Option<Retained<NSArray<UINavigationItem>>>;
193
194        #[cfg(feature = "UINavigationItem")]
195        /// Setter for [`items`][Self::items].
196        #[unsafe(method(setItems:))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn setItems(&self, items: Option<&NSArray<UINavigationItem>>);
199
200        #[cfg(feature = "UINavigationItem")]
201        #[unsafe(method(setItems:animated:))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn setItems_animated(
204            &self,
205            items: Option<&NSArray<UINavigationItem>>,
206            animated: bool,
207        );
208
209        /// When set to YES, the navigation bar will use a larger out-of-line title view when requested by the current navigation item. To specify when the large out-of-line title view appears, see UINavigationItem.largeTitleDisplayMode. Defaults to NO.
210        #[unsafe(method(prefersLargeTitles))]
211        #[unsafe(method_family = none)]
212        pub unsafe fn prefersLargeTitles(&self) -> bool;
213
214        /// Setter for [`prefersLargeTitles`][Self::prefersLargeTitles].
215        #[unsafe(method(setPrefersLargeTitles:))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn setPrefersLargeTitles(&self, prefers_large_titles: bool);
218
219        /// The toolbar section that this navigation bar is currently using.
220        #[unsafe(method(currentNSToolbarSection))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn currentNSToolbarSection(&self) -> UINavigationBarNSToolbarSection;
223
224        #[cfg(feature = "UIBehavioralStyle")]
225        /// The concrete behavioral style chosen for the navigation bar. When this resolves to .mac, the navigation bar's contents are placed in the NSToolbar.
226        #[unsafe(method(behavioralStyle))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn behavioralStyle(&self) -> UIBehavioralStyle;
229
230        #[cfg(feature = "UIBehavioralStyle")]
231        /// The requested behavioral style for the navigation bar.
232        #[unsafe(method(preferredBehavioralStyle))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn preferredBehavioralStyle(&self) -> UIBehavioralStyle;
235
236        #[cfg(feature = "UIBehavioralStyle")]
237        /// Setter for [`preferredBehavioralStyle`][Self::preferredBehavioralStyle].
238        #[unsafe(method(setPreferredBehavioralStyle:))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn setPreferredBehavioralStyle(
241            &self,
242            preferred_behavioral_style: UIBehavioralStyle,
243        );
244
245        #[cfg(feature = "UIColor")]
246        #[unsafe(method(tintColor))]
247        #[unsafe(method_family = none)]
248        pub unsafe fn tintColor(&self) -> Option<Retained<UIColor>>;
249
250        #[cfg(feature = "UIColor")]
251        /// Setter for [`tintColor`][Self::tintColor].
252        #[unsafe(method(setTintColor:))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn setTintColor(&self, tint_color: Option<&UIColor>);
255
256        #[cfg(feature = "UIColor")]
257        #[unsafe(method(barTintColor))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn barTintColor(&self) -> Option<Retained<UIColor>>;
260
261        #[cfg(feature = "UIColor")]
262        /// Setter for [`barTintColor`][Self::barTintColor].
263        #[unsafe(method(setBarTintColor:))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn setBarTintColor(&self, bar_tint_color: Option<&UIColor>);
266
267        #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
268        #[unsafe(method(setBackgroundImage:forBarPosition:barMetrics:))]
269        #[unsafe(method_family = none)]
270        pub unsafe fn setBackgroundImage_forBarPosition_barMetrics(
271            &self,
272            background_image: Option<&UIImage>,
273            bar_position: UIBarPosition,
274            bar_metrics: UIBarMetrics,
275        );
276
277        #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
278        #[unsafe(method(backgroundImageForBarPosition:barMetrics:))]
279        #[unsafe(method_family = none)]
280        pub unsafe fn backgroundImageForBarPosition_barMetrics(
281            &self,
282            bar_position: UIBarPosition,
283            bar_metrics: UIBarMetrics,
284        ) -> Option<Retained<UIImage>>;
285
286        #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
287        #[unsafe(method(setBackgroundImage:forBarMetrics:))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn setBackgroundImage_forBarMetrics(
290            &self,
291            background_image: Option<&UIImage>,
292            bar_metrics: UIBarMetrics,
293        );
294
295        #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
296        #[unsafe(method(backgroundImageForBarMetrics:))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn backgroundImageForBarMetrics(
299            &self,
300            bar_metrics: UIBarMetrics,
301        ) -> Option<Retained<UIImage>>;
302
303        #[cfg(feature = "UIImage")]
304        #[unsafe(method(shadowImage))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn shadowImage(&self) -> Option<Retained<UIImage>>;
307
308        #[cfg(feature = "UIImage")]
309        /// Setter for [`shadowImage`][Self::shadowImage].
310        #[unsafe(method(setShadowImage:))]
311        #[unsafe(method_family = none)]
312        pub unsafe fn setShadowImage(&self, shadow_image: Option<&UIImage>);
313
314        #[unsafe(method(titleTextAttributes))]
315        #[unsafe(method_family = none)]
316        pub unsafe fn titleTextAttributes(
317            &self,
318        ) -> Option<Retained<NSDictionary<NSAttributedStringKey, AnyObject>>>;
319
320        /// Setter for [`titleTextAttributes`][Self::titleTextAttributes].
321        #[unsafe(method(setTitleTextAttributes:))]
322        #[unsafe(method_family = none)]
323        pub unsafe fn setTitleTextAttributes(
324            &self,
325            title_text_attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
326        );
327
328        #[unsafe(method(largeTitleTextAttributes))]
329        #[unsafe(method_family = none)]
330        pub unsafe fn largeTitleTextAttributes(
331            &self,
332        ) -> Option<Retained<NSDictionary<NSAttributedStringKey, AnyObject>>>;
333
334        /// Setter for [`largeTitleTextAttributes`][Self::largeTitleTextAttributes].
335        #[unsafe(method(setLargeTitleTextAttributes:))]
336        #[unsafe(method_family = none)]
337        pub unsafe fn setLargeTitleTextAttributes(
338            &self,
339            large_title_text_attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
340        );
341
342        #[cfg(all(feature = "UIBarCommon", feature = "objc2-core-foundation"))]
343        #[unsafe(method(setTitleVerticalPositionAdjustment:forBarMetrics:))]
344        #[unsafe(method_family = none)]
345        pub unsafe fn setTitleVerticalPositionAdjustment_forBarMetrics(
346            &self,
347            adjustment: CGFloat,
348            bar_metrics: UIBarMetrics,
349        );
350
351        #[cfg(all(feature = "UIBarCommon", feature = "objc2-core-foundation"))]
352        #[unsafe(method(titleVerticalPositionAdjustmentForBarMetrics:))]
353        #[unsafe(method_family = none)]
354        pub unsafe fn titleVerticalPositionAdjustmentForBarMetrics(
355            &self,
356            bar_metrics: UIBarMetrics,
357        ) -> CGFloat;
358
359        #[cfg(feature = "UIImage")]
360        #[unsafe(method(backIndicatorImage))]
361        #[unsafe(method_family = none)]
362        pub unsafe fn backIndicatorImage(&self) -> Option<Retained<UIImage>>;
363
364        #[cfg(feature = "UIImage")]
365        /// Setter for [`backIndicatorImage`][Self::backIndicatorImage].
366        #[unsafe(method(setBackIndicatorImage:))]
367        #[unsafe(method_family = none)]
368        pub unsafe fn setBackIndicatorImage(&self, back_indicator_image: Option<&UIImage>);
369
370        #[cfg(feature = "UIImage")]
371        #[unsafe(method(backIndicatorTransitionMaskImage))]
372        #[unsafe(method_family = none)]
373        pub unsafe fn backIndicatorTransitionMaskImage(&self) -> Option<Retained<UIImage>>;
374
375        #[cfg(feature = "UIImage")]
376        /// Setter for [`backIndicatorTransitionMaskImage`][Self::backIndicatorTransitionMaskImage].
377        #[unsafe(method(setBackIndicatorTransitionMaskImage:))]
378        #[unsafe(method_family = none)]
379        pub unsafe fn setBackIndicatorTransitionMaskImage(
380            &self,
381            back_indicator_transition_mask_image: Option<&UIImage>,
382        );
383
384        #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
385        /// Describes the appearance attributes for the navigation bar to use when it is displayed with its standard height.
386        #[unsafe(method(standardAppearance))]
387        #[unsafe(method_family = none)]
388        pub unsafe fn standardAppearance(&self) -> Retained<UINavigationBarAppearance>;
389
390        #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
391        /// Setter for [`standardAppearance`][Self::standardAppearance].
392        #[unsafe(method(setStandardAppearance:))]
393        #[unsafe(method_family = none)]
394        pub unsafe fn setStandardAppearance(&self, standard_appearance: &UINavigationBarAppearance);
395
396        #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
397        /// Describes the appearance attributes for the navigation bar to use when it is displayed with its compact height. If not set, the standardAppearance will be used instead.
398        #[unsafe(method(compactAppearance))]
399        #[unsafe(method_family = none)]
400        pub unsafe fn compactAppearance(&self) -> Option<Retained<UINavigationBarAppearance>>;
401
402        #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
403        /// Setter for [`compactAppearance`][Self::compactAppearance].
404        #[unsafe(method(setCompactAppearance:))]
405        #[unsafe(method_family = none)]
406        pub unsafe fn setCompactAppearance(
407            &self,
408            compact_appearance: Option<&UINavigationBarAppearance>,
409        );
410
411        #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
412        /// Describes the appearance attributes for the navigation bar to use when an associated UIScrollView has reached the edge abutting the bar (the top edge for the navigation bar). If not set, a modified standardAppearance will be used instead.
413        #[unsafe(method(scrollEdgeAppearance))]
414        #[unsafe(method_family = none)]
415        pub unsafe fn scrollEdgeAppearance(&self) -> Option<Retained<UINavigationBarAppearance>>;
416
417        #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
418        /// Setter for [`scrollEdgeAppearance`][Self::scrollEdgeAppearance].
419        #[unsafe(method(setScrollEdgeAppearance:))]
420        #[unsafe(method_family = none)]
421        pub unsafe fn setScrollEdgeAppearance(
422            &self,
423            scroll_edge_appearance: Option<&UINavigationBarAppearance>,
424        );
425
426        #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
427        /// Describes the appearance attributes for the navigation bar to use when it is displayed with its compact heights, and an associated UIScrollView has reached the edge abutting the bar. If not set, first the scrollEdgeAppearance will be tried, and if that is nil then compactAppearance followed by a modified standardAppearance.
428        #[unsafe(method(compactScrollEdgeAppearance))]
429        #[unsafe(method_family = none)]
430        pub unsafe fn compactScrollEdgeAppearance(
431            &self,
432        ) -> Option<Retained<UINavigationBarAppearance>>;
433
434        #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
435        /// Setter for [`compactScrollEdgeAppearance`][Self::compactScrollEdgeAppearance].
436        #[unsafe(method(setCompactScrollEdgeAppearance:))]
437        #[unsafe(method_family = none)]
438        pub unsafe fn setCompactScrollEdgeAppearance(
439            &self,
440            compact_scroll_edge_appearance: Option<&UINavigationBarAppearance>,
441        );
442    );
443}
444
445/// Methods declared on superclass `UIView`.
446#[cfg(all(feature = "UIResponder", feature = "UIView"))]
447impl UINavigationBar {
448    extern_methods!(
449        #[cfg(feature = "objc2-core-foundation")]
450        #[unsafe(method(initWithFrame:))]
451        #[unsafe(method_family = init)]
452        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
453
454        #[unsafe(method(initWithCoder:))]
455        #[unsafe(method_family = init)]
456        pub unsafe fn initWithCoder(
457            this: Allocated<Self>,
458            coder: &NSCoder,
459        ) -> Option<Retained<Self>>;
460    );
461}
462
463/// Methods declared on superclass `NSObject`.
464#[cfg(all(feature = "UIResponder", feature = "UIView"))]
465impl UINavigationBar {
466    extern_methods!(
467        #[unsafe(method(init))]
468        #[unsafe(method_family = init)]
469        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
470
471        #[unsafe(method(new))]
472        #[unsafe(method_family = new)]
473        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
474    );
475}
476
477extern_protocol!(
478    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uinavigationbardelegate?language=objc)
479    #[cfg(feature = "UIBarCommon")]
480    pub unsafe trait UINavigationBarDelegate:
481        UIBarPositioningDelegate + MainThreadOnly
482    {
483        #[cfg(all(
484            feature = "UINavigationItem",
485            feature = "UIResponder",
486            feature = "UIView"
487        ))]
488        #[optional]
489        #[unsafe(method(navigationBar:shouldPushItem:))]
490        #[unsafe(method_family = none)]
491        unsafe fn navigationBar_shouldPushItem(
492            &self,
493            navigation_bar: &UINavigationBar,
494            item: &UINavigationItem,
495        ) -> bool;
496
497        #[cfg(all(
498            feature = "UINavigationItem",
499            feature = "UIResponder",
500            feature = "UIView"
501        ))]
502        #[optional]
503        #[unsafe(method(navigationBar:didPushItem:))]
504        #[unsafe(method_family = none)]
505        unsafe fn navigationBar_didPushItem(
506            &self,
507            navigation_bar: &UINavigationBar,
508            item: &UINavigationItem,
509        );
510
511        #[cfg(all(
512            feature = "UINavigationItem",
513            feature = "UIResponder",
514            feature = "UIView"
515        ))]
516        #[optional]
517        #[unsafe(method(navigationBar:shouldPopItem:))]
518        #[unsafe(method_family = none)]
519        unsafe fn navigationBar_shouldPopItem(
520            &self,
521            navigation_bar: &UINavigationBar,
522            item: &UINavigationItem,
523        ) -> bool;
524
525        #[cfg(all(
526            feature = "UINavigationItem",
527            feature = "UIResponder",
528            feature = "UIView"
529        ))]
530        #[optional]
531        #[unsafe(method(navigationBar:didPopItem:))]
532        #[unsafe(method_family = none)]
533        unsafe fn navigationBar_didPopItem(
534            &self,
535            navigation_bar: &UINavigationBar,
536            item: &UINavigationItem,
537        );
538
539        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
540        /// Which section of the NSToolbar this navigation bar should use when attempting to host in an NSToolbar. Returning 'None' will disable NSToolbar hosting as if preferredBehavioralStyle were set to 'Pad' The specific section returned will also affect how the navigation bar presents in that section.
541        #[optional]
542        #[unsafe(method(navigationBarNSToolbarSection:))]
543        #[unsafe(method_family = none)]
544        unsafe fn navigationBarNSToolbarSection(
545            &self,
546            navigation_bar: &UINavigationBar,
547        ) -> UINavigationBarNSToolbarSection;
548    }
549);