inamiy / OrientationKit

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

License:MIT License


Languages

Language:Swift 100.0%