Skip to content

Latest commit

 

History

42 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bevy_ios_safearea

Following released Bevy versions crates.io docs.rs discord

Bevy plugin to query iOS and tvOS device safe area insets.

demo

Features

  • reads safe area on app start
  • easy access via a resource
  • noop on platforms without safe areas (no cfgs needed in your app code)
  • pure Rust + objc2 on the iOS/tvOS side — no Swift Package, no Xcode SPM step

On tvOS the same UIView.safeAreaInsets (11.0+) reports the overscan margin — the border a television may decline to display — so treating these insets as a floor for your own padding is what keeps a HUD out of the croppable edge of the screen.

Instructions

1. Add the dependency

Plain [dependencies], not target-gated — that's what "no cfgs needed in your app code" above means. The only UIKit-specific bit (objc2-ui-kit) is gated inside this crate's own Cargo.toml, not the consumer's.

On tvOS there is a caveat that is not ours: winit 0.30 has no tvOS support at all — it misses the apple cfg alias, is unix, and so compiles its X11/Wayland backend for an Apple TV. Since this crate depends on winit (to reach the UIWindow behind Bevy's window), a tvOS build only resolves in a workspace that patches winit itself. That is also why CI has no tvOS leg here: there is nothing to gate on until upstream winit builds for the platform.

[dependencies]
bevy_ios_safearea = "0.7"

2. Setup Plugin in Bevy

Initialize Bevy Plugin:

// request initialisation right on startup
use bevy::prelude::*;
App::new()
    .add_plugins((DefaultPlugins,bevy_ios_safearea::IosSafeAreaPlugin));

Accessing it:

use bevy::prelude::*;
use bevy_ios_safearea::IosSafeArea;

fn bevy_system(safe_area: IosSafeArea) {
    let safe_area_top = safe_area.top();
}

Our Other Crates

Bevy version support

bevy crate
0.19 0.6,0.7,main
0.18 0.5
0.17 0.4
0.16 0.3
0.15 0.1,0.2

License

All code in this repository is dual-licensed under either:

at your option. This means you can select the license you prefer.

Your contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Bevy plugin to query ios device safe area insets

Topics

Resources

Stars

12 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Contributors

Languages