1use 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#[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 #[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 fn barStyle(&self) -> UIBarStyle;
133
134 #[cfg(feature = "UIInterface")]
135 #[unsafe(method(setBarStyle:))]
137 #[unsafe(method_family = none)]
138 pub fn setBarStyle(&self, bar_style: UIBarStyle);
139
140 #[cfg(feature = "UIBarCommon")]
141 #[unsafe(method(delegate))]
142 #[unsafe(method_family = none)]
143 pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn UINavigationBarDelegate>>>;
144
145 #[cfg(feature = "UIBarCommon")]
146 #[unsafe(method(setDelegate:))]
150 #[unsafe(method_family = none)]
151 pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn UINavigationBarDelegate>>);
152
153 #[unsafe(method(isTranslucent))]
154 #[unsafe(method_family = none)]
155 pub fn isTranslucent(&self) -> bool;
156
157 #[unsafe(method(setTranslucent:))]
159 #[unsafe(method_family = none)]
160 pub fn setTranslucent(&self, translucent: bool);
161
162 #[cfg(feature = "UINavigationItem")]
163 #[unsafe(method(pushNavigationItem:animated:))]
164 #[unsafe(method_family = none)]
165 pub fn pushNavigationItem_animated(&self, item: &UINavigationItem, animated: bool);
166
167 #[cfg(feature = "UINavigationItem")]
168 #[unsafe(method(popNavigationItemAnimated:))]
169 #[unsafe(method_family = none)]
170 pub fn popNavigationItemAnimated(
171 &self,
172 animated: bool,
173 ) -> Option<Retained<UINavigationItem>>;
174
175 #[cfg(feature = "UINavigationItem")]
176 #[unsafe(method(topItem))]
177 #[unsafe(method_family = none)]
178 pub fn topItem(&self) -> Option<Retained<UINavigationItem>>;
179
180 #[cfg(feature = "UINavigationItem")]
181 #[unsafe(method(backItem))]
182 #[unsafe(method_family = none)]
183 pub fn backItem(&self) -> Option<Retained<UINavigationItem>>;
184
185 #[cfg(feature = "UINavigationItem")]
186 #[unsafe(method(items))]
187 #[unsafe(method_family = none)]
188 pub fn items(&self) -> Option<Retained<NSArray<UINavigationItem>>>;
189
190 #[cfg(feature = "UINavigationItem")]
191 #[unsafe(method(setItems:))]
195 #[unsafe(method_family = none)]
196 pub fn setItems(&self, items: Option<&NSArray<UINavigationItem>>);
197
198 #[cfg(feature = "UINavigationItem")]
199 #[unsafe(method(setItems:animated:))]
200 #[unsafe(method_family = none)]
201 pub fn setItems_animated(&self, items: Option<&NSArray<UINavigationItem>>, animated: bool);
202
203 #[unsafe(method(prefersLargeTitles))]
205 #[unsafe(method_family = none)]
206 pub fn prefersLargeTitles(&self) -> bool;
207
208 #[unsafe(method(setPrefersLargeTitles:))]
210 #[unsafe(method_family = none)]
211 pub fn setPrefersLargeTitles(&self, prefers_large_titles: bool);
212
213 #[unsafe(method(currentNSToolbarSection))]
215 #[unsafe(method_family = none)]
216 pub fn currentNSToolbarSection(&self) -> UINavigationBarNSToolbarSection;
217
218 #[cfg(feature = "UIBehavioralStyle")]
219 #[unsafe(method(behavioralStyle))]
221 #[unsafe(method_family = none)]
222 pub fn behavioralStyle(&self) -> UIBehavioralStyle;
223
224 #[cfg(feature = "UIBehavioralStyle")]
225 #[unsafe(method(preferredBehavioralStyle))]
227 #[unsafe(method_family = none)]
228 pub fn preferredBehavioralStyle(&self) -> UIBehavioralStyle;
229
230 #[cfg(feature = "UIBehavioralStyle")]
231 #[unsafe(method(setPreferredBehavioralStyle:))]
233 #[unsafe(method_family = none)]
234 pub fn setPreferredBehavioralStyle(&self, preferred_behavioral_style: UIBehavioralStyle);
235
236 #[cfg(feature = "UIColor")]
237 #[unsafe(method(tintColor))]
238 #[unsafe(method_family = none)]
239 pub fn tintColor(&self) -> Option<Retained<UIColor>>;
240
241 #[cfg(feature = "UIColor")]
242 #[unsafe(method(setTintColor:))]
248 #[unsafe(method_family = none)]
249 pub unsafe fn setTintColor(&self, tint_color: Option<&UIColor>);
250
251 #[cfg(feature = "UIColor")]
252 #[unsafe(method(barTintColor))]
253 #[unsafe(method_family = none)]
254 pub fn barTintColor(&self) -> Option<Retained<UIColor>>;
255
256 #[cfg(feature = "UIColor")]
257 #[unsafe(method(setBarTintColor:))]
259 #[unsafe(method_family = none)]
260 pub fn setBarTintColor(&self, bar_tint_color: Option<&UIColor>);
261
262 #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
263 #[unsafe(method(setBackgroundImage:forBarPosition:barMetrics:))]
264 #[unsafe(method_family = none)]
265 pub fn setBackgroundImage_forBarPosition_barMetrics(
266 &self,
267 background_image: Option<&UIImage>,
268 bar_position: UIBarPosition,
269 bar_metrics: UIBarMetrics,
270 );
271
272 #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
273 #[unsafe(method(backgroundImageForBarPosition:barMetrics:))]
274 #[unsafe(method_family = none)]
275 pub fn backgroundImageForBarPosition_barMetrics(
276 &self,
277 bar_position: UIBarPosition,
278 bar_metrics: UIBarMetrics,
279 ) -> Option<Retained<UIImage>>;
280
281 #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
282 #[unsafe(method(setBackgroundImage:forBarMetrics:))]
283 #[unsafe(method_family = none)]
284 pub fn setBackgroundImage_forBarMetrics(
285 &self,
286 background_image: Option<&UIImage>,
287 bar_metrics: UIBarMetrics,
288 );
289
290 #[cfg(all(feature = "UIBarCommon", feature = "UIImage"))]
291 #[unsafe(method(backgroundImageForBarMetrics:))]
292 #[unsafe(method_family = none)]
293 pub fn backgroundImageForBarMetrics(
294 &self,
295 bar_metrics: UIBarMetrics,
296 ) -> Option<Retained<UIImage>>;
297
298 #[cfg(feature = "UIImage")]
299 #[unsafe(method(shadowImage))]
300 #[unsafe(method_family = none)]
301 pub fn shadowImage(&self) -> Option<Retained<UIImage>>;
302
303 #[cfg(feature = "UIImage")]
304 #[unsafe(method(setShadowImage:))]
306 #[unsafe(method_family = none)]
307 pub fn setShadowImage(&self, shadow_image: Option<&UIImage>);
308
309 #[unsafe(method(titleTextAttributes))]
310 #[unsafe(method_family = none)]
311 pub fn titleTextAttributes(
312 &self,
313 ) -> Option<Retained<NSDictionary<NSAttributedStringKey, AnyObject>>>;
314
315 #[unsafe(method(setTitleTextAttributes:))]
323 #[unsafe(method_family = none)]
324 pub unsafe fn setTitleTextAttributes(
325 &self,
326 title_text_attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
327 );
328
329 #[unsafe(method(largeTitleTextAttributes))]
330 #[unsafe(method_family = none)]
331 pub fn largeTitleTextAttributes(
332 &self,
333 ) -> Option<Retained<NSDictionary<NSAttributedStringKey, AnyObject>>>;
334
335 #[unsafe(method(setLargeTitleTextAttributes:))]
343 #[unsafe(method_family = none)]
344 pub unsafe fn setLargeTitleTextAttributes(
345 &self,
346 large_title_text_attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
347 );
348
349 #[cfg(all(feature = "UIBarCommon", feature = "objc2-core-foundation"))]
350 #[unsafe(method(setTitleVerticalPositionAdjustment:forBarMetrics:))]
351 #[unsafe(method_family = none)]
352 pub fn setTitleVerticalPositionAdjustment_forBarMetrics(
353 &self,
354 adjustment: CGFloat,
355 bar_metrics: UIBarMetrics,
356 );
357
358 #[cfg(all(feature = "UIBarCommon", feature = "objc2-core-foundation"))]
359 #[unsafe(method(titleVerticalPositionAdjustmentForBarMetrics:))]
360 #[unsafe(method_family = none)]
361 pub fn titleVerticalPositionAdjustmentForBarMetrics(
362 &self,
363 bar_metrics: UIBarMetrics,
364 ) -> CGFloat;
365
366 #[cfg(feature = "UIImage")]
367 #[unsafe(method(backIndicatorImage))]
368 #[unsafe(method_family = none)]
369 pub fn backIndicatorImage(&self) -> Option<Retained<UIImage>>;
370
371 #[cfg(feature = "UIImage")]
372 #[unsafe(method(setBackIndicatorImage:))]
374 #[unsafe(method_family = none)]
375 pub fn setBackIndicatorImage(&self, back_indicator_image: Option<&UIImage>);
376
377 #[cfg(feature = "UIImage")]
378 #[unsafe(method(backIndicatorTransitionMaskImage))]
379 #[unsafe(method_family = none)]
380 pub fn backIndicatorTransitionMaskImage(&self) -> Option<Retained<UIImage>>;
381
382 #[cfg(feature = "UIImage")]
383 #[unsafe(method(setBackIndicatorTransitionMaskImage:))]
385 #[unsafe(method_family = none)]
386 pub fn setBackIndicatorTransitionMaskImage(
387 &self,
388 back_indicator_transition_mask_image: Option<&UIImage>,
389 );
390
391 #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
392 #[unsafe(method(standardAppearance))]
394 #[unsafe(method_family = none)]
395 pub fn standardAppearance(&self) -> Retained<UINavigationBarAppearance>;
396
397 #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
398 #[unsafe(method(setStandardAppearance:))]
402 #[unsafe(method_family = none)]
403 pub fn setStandardAppearance(&self, standard_appearance: &UINavigationBarAppearance);
404
405 #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
406 #[unsafe(method(compactAppearance))]
408 #[unsafe(method_family = none)]
409 pub fn compactAppearance(&self) -> Option<Retained<UINavigationBarAppearance>>;
410
411 #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
412 #[unsafe(method(setCompactAppearance:))]
416 #[unsafe(method_family = none)]
417 pub fn setCompactAppearance(&self, compact_appearance: Option<&UINavigationBarAppearance>);
418
419 #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
420 #[unsafe(method(scrollEdgeAppearance))]
422 #[unsafe(method_family = none)]
423 pub fn scrollEdgeAppearance(&self) -> Option<Retained<UINavigationBarAppearance>>;
424
425 #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
426 #[unsafe(method(setScrollEdgeAppearance:))]
430 #[unsafe(method_family = none)]
431 pub fn setScrollEdgeAppearance(
432 &self,
433 scroll_edge_appearance: Option<&UINavigationBarAppearance>,
434 );
435
436 #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
437 #[unsafe(method(compactScrollEdgeAppearance))]
439 #[unsafe(method_family = none)]
440 pub fn compactScrollEdgeAppearance(&self) -> Option<Retained<UINavigationBarAppearance>>;
441
442 #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
443 #[unsafe(method(setCompactScrollEdgeAppearance:))]
447 #[unsafe(method_family = none)]
448 pub fn setCompactScrollEdgeAppearance(
449 &self,
450 compact_scroll_edge_appearance: Option<&UINavigationBarAppearance>,
451 );
452 );
453}
454
455#[cfg(all(feature = "UIResponder", feature = "UIView"))]
457impl UINavigationBar {
458 extern_methods!(
459 #[cfg(feature = "objc2-core-foundation")]
460 #[unsafe(method(initWithFrame:))]
461 #[unsafe(method_family = init)]
462 pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
463
464 #[unsafe(method(initWithCoder:))]
468 #[unsafe(method_family = init)]
469 pub unsafe fn initWithCoder(
470 this: Allocated<Self>,
471 coder: &NSCoder,
472 ) -> Option<Retained<Self>>;
473
474 #[unsafe(method(init))]
475 #[unsafe(method_family = init)]
476 pub fn init(this: Allocated<Self>) -> Retained<Self>;
477 );
478}
479
480#[cfg(all(feature = "UIResponder", feature = "UIView"))]
482impl UINavigationBar {
483 extern_methods!(
484 #[unsafe(method(new))]
485 #[unsafe(method_family = new)]
486 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
487 );
488}
489
490extern_protocol!(
491 #[cfg(feature = "UIBarCommon")]
493 pub unsafe trait UINavigationBarDelegate:
494 UIBarPositioningDelegate + MainThreadOnly
495 {
496 #[cfg(all(
497 feature = "UINavigationItem",
498 feature = "UIResponder",
499 feature = "UIView"
500 ))]
501 #[optional]
502 #[unsafe(method(navigationBar:shouldPushItem:))]
503 #[unsafe(method_family = none)]
504 fn navigationBar_shouldPushItem(
505 &self,
506 navigation_bar: &UINavigationBar,
507 item: &UINavigationItem,
508 ) -> bool;
509
510 #[cfg(all(
511 feature = "UINavigationItem",
512 feature = "UIResponder",
513 feature = "UIView"
514 ))]
515 #[optional]
516 #[unsafe(method(navigationBar:didPushItem:))]
517 #[unsafe(method_family = none)]
518 fn navigationBar_didPushItem(
519 &self,
520 navigation_bar: &UINavigationBar,
521 item: &UINavigationItem,
522 );
523
524 #[cfg(all(
525 feature = "UINavigationItem",
526 feature = "UIResponder",
527 feature = "UIView"
528 ))]
529 #[optional]
530 #[unsafe(method(navigationBar:shouldPopItem:))]
531 #[unsafe(method_family = none)]
532 fn navigationBar_shouldPopItem(
533 &self,
534 navigation_bar: &UINavigationBar,
535 item: &UINavigationItem,
536 ) -> bool;
537
538 #[cfg(all(
539 feature = "UINavigationItem",
540 feature = "UIResponder",
541 feature = "UIView"
542 ))]
543 #[optional]
544 #[unsafe(method(navigationBar:didPopItem:))]
545 #[unsafe(method_family = none)]
546 fn navigationBar_didPopItem(
547 &self,
548 navigation_bar: &UINavigationBar,
549 item: &UINavigationItem,
550 );
551
552 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
553 #[optional]
555 #[unsafe(method(navigationBarNSToolbarSection:))]
556 #[unsafe(method_family = none)]
557 fn navigationBarNSToolbarSection(
558 &self,
559 navigation_bar: &UINavigationBar,
560 ) -> UINavigationBarNSToolbarSection;
561 }
562);