Skip to content

Commit 94b9fe3

Browse files
authored
can hide status bar on iOS (bevyengine#17179)
# Objective - I want to hide the clock and the battery indicator on iOS ## Solution - Add the platform specific property `prefers_status_bar_hidden` on Window creation, and map it to `with_prefers_status_bar_hidden` in winit. ## Testing - Tested on iOS
1 parent 1162e03 commit 94b9fe3

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

crates/bevy_window/src/window.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,16 @@ pub struct Window {
412412
///
413413
/// [`WindowAttributesExtIOS::with_prefers_home_indicator_hidden`]: https://docs.rs/winit/latest/x86_64-apple-darwin/winit/platform/ios/trait.WindowAttributesExtIOS.html#tymethod.with_prefers_home_indicator_hidden
414414
pub prefers_home_indicator_hidden: bool,
415+
/// Sets whether the Window prefers the status bar hidden.
416+
///
417+
/// Corresponds to [`WindowAttributesExtIOS::with_prefers_status_bar_hidden`].
418+
///
419+
/// # Platform-specific
420+
///
421+
/// - Only used on iOS.
422+
///
423+
/// [`WindowAttributesExtIOS::with_prefers_status_bar_hidden`]: https://docs.rs/winit/latest/x86_64-apple-darwin/winit/platform/ios/trait.WindowAttributesExtIOS.html#tymethod.with_prefers_status_bar_hidden
424+
pub prefers_status_bar_hidden: bool,
415425
}
416426

417427
impl Default for Window {
@@ -454,6 +464,7 @@ impl Default for Window {
454464
titlebar_show_title: true,
455465
titlebar_show_buttons: true,
456466
prefers_home_indicator_hidden: false,
467+
prefers_status_bar_hidden: false,
457468
}
458469
}
459470
}

crates/bevy_winit/src/winit_windows.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ impl WinitWindows {
147147
use winit::platform::ios::WindowAttributesExtIOS;
148148
winit_window_attributes = winit_window_attributes
149149
.with_prefers_home_indicator_hidden(window.prefers_home_indicator_hidden);
150+
winit_window_attributes = winit_window_attributes
151+
.with_prefers_status_bar_hidden(window.prefers_status_bar_hidden);
150152
}
151153

152154
let display_info = DisplayInfo {

examples/mobile/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ fn main() {
3030
recognize_rotation_gesture: true,
3131
// Only has an effect on iOS
3232
prefers_home_indicator_hidden: true,
33+
// Only has an effect on iOS
34+
prefers_status_bar_hidden: true,
3335
..default()
3436
}),
3537
..default()

0 commit comments

Comments
 (0)