Skip to content

iOS device/interface/image/video orientation translation & detection using CoreMotion + SwiftUI + Combine.

License

Notifications You must be signed in to change notification settings

inamiy/OrientationKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OrientationKit

iOS device/interface/image/video orientation translation & detection using CoreMotion + SwiftUI + Combine.

How to Use

@main
struct DemoApp: App {
    var body: some Scene {
        WindowGroup {
            // Call `.withOrientations()` to start observing 
            // CoreMotion-based device orientation changes.
            // This keeps notifying even when device orientation
            // is locked.
            ContentView()
                .withOrientations()
        }
    }
}

struct ContentView: View {
    @Environment(\.deviceOrientation)
    private var deviceOrientation

    @Environment(\.interfaceOrientation)
    private var interfaceOrientation

    /// - Note: To grab other `OrientationManager`'s properties
    /// e.g. `deviceMotion`, just access via `@EnvironmentObject`.
    @EnvironmentObject
    private var manager: OrientationManager

    var body: some View {
        ...
    }
}

Example

See Examples for more information.

License

MIT

About

iOS device/interface/image/video orientation translation & detection using CoreMotion + SwiftUI + Combine.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages