Skip to content

Latest commit

 

History

History
64 lines (42 loc) · 2.01 KB

File metadata and controls

64 lines (42 loc) · 2.01 KB

ReflectionView

2017-10-19 23 09 58 (ReflectionView running in ARKitExample)

Have a complex rendering pipeline? Can the end-result of your pipeline be nested in a single UIView? Do you need that view to present itself as two duplicate views so the view will appear as a single image when viewed through a VR headset?

You've found the most useful highly niche library for AR/VR yet.

I've used this to:

  • Replicate a react-native rendered app overlay for stereoscopic presentation
  • Replicate an ARKit renderer and allow "stereoscopic on rotation" experiences.

How to use

  1. Create constraints so that the ReflectionView instance takes half the screen
  2. Put the views you want doubled inside the ReflectionView

image

Auto-flipping on rotation

You'll need to create two layouts, one for portrait, another for landscape. See https://medium.com/@craiggrummitt/size-classes-in-interface-builder-in-xcode-8-74f20a541195.

Then you'll need something like this:

  override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) {
    coordinator.animate(alongsideTransition: { (_) in
        let orient = UIApplication.shared.statusBarOrientation

        switch orient {
        case .portrait:
            self.reflectionView.replicator.instanceCount = 1
         default:
            self.reflectionView.replicator.instanceCount = 2
        }
    }, completion: nil)

    super.willTransition(to: newCollection, with: coordinator)
  }

Apps using this library

License

MIT

Feeling thankful?

BTC: 1NEf77g7aFpsLGXf88ie1Bueze7QxbH2mN ETH: 0x428D3ebACfe19a33B6265C20FFffb25cEB45df0A

Twitter: @tastycode