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