Repolode
elijah-semyonov

elijah-semyonov/DuoLikeAnimation

An iOS demo that uses SwiftUI Metal shaders and Core Motion to mimic the folding animation of a foldable iPhone, making the screen look like frosted glass.

Stars
158
Forks
40
Open issues
0
Last commit
last month

What is it?

DuoLikeAnimation is an iOS demo project that imitates the folding animation of the iPhone Duo using only SwiftUI shaders and Core Motion. A Metal layerEffect receives live device attitude, so a flat phone appears to fold like one half of a foldable device.

The effect treats the screen as a pane of frosted glass. The interface stays fixed in world space while the device tilts around its vertical axis. The shader reprojects the view through perspective, blurs it and darkens it in proportion to the gap between the glass and the interface plane, and renders black where rays miss the interface. The viewer's eye is modeled at a hand-held distance of 320 mm by default.

The project includes the shader, a SwiftUI modifier with tunable parameters, a Core Motion model that calibrates the zero-tilt pose, and a demo view with a recalibration and manual tilt panel. On the simulator, where no motion data is available, manual tilt is enabled by default.

Key features

  • 01Metal layerEffect shader performs perspective reprojection, distance-based blur and darkening.
  • 02Core Motion supplies device attitude and calibrates the zero-tilt pose from the first sample.
  • 03A .foldEffect(angle:parameters:) modifier exposes tunable parameters.
  • 04A floating panel supports recalibration and manual tilt.
  • 05Manual tilt is enabled by default on the simulator.

Use cases

  • Learning how to write SwiftUI layerEffect shaders with Metal.
  • Prototyping foldable-device or 3D-tilt interface effects on iOS.
  • Studying how Core Motion attitude data can drive visual effects.

Quick start

  1. 1

    Open DuoLikeAnimation.xcodeproj in Xcode

  2. 2

    Run the app on an iOS device (the simulator has no motion data and uses manual tilt)

Things to know

  • Built for iOS only, and the real tilt effect needs a physical device with motion sensors.
  • It is a demo project rather than a reusable library.

Topics

FAQ

What is DuoLikeAnimation?
An iOS demo that uses SwiftUI Metal shaders and Core Motion to mimic the folding animation of a foldable iPhone, making the screen look like frosted glass. DuoLikeAnimation is an iOS demo project that imitates the folding animation of the iPhone Duo using only SwiftUI shaders and Core Motion. A Metal layerEffect receives live device attitude, so a flat phone appears to fold like one half of a foldable device.
Is DuoLikeAnimation free to use? What license does it have?
DuoLikeAnimation is open source under the MIT license. Check the license terms before using it in commercial products.
Is DuoLikeAnimation still maintained?
Updated within 6 months. The last commit to DuoLikeAnimation was on Sep 11, 2026.
What can I use DuoLikeAnimation for?
Learning how to write SwiftUI layerEffect shaders with Metal. Prototyping foldable-device or 3D-tilt interface effects on iOS. Studying how Core Motion attitude data can drive visual effects.
How do I install DuoLikeAnimation?
Open DuoLikeAnimation.xcodeproj in Xcode Run the app on an iOS device (the simulator has no motion data and uses manual tilt)
Where can I get DuoLikeAnimation?
The source code and installation instructions are on GitHub: https://github.com/elijah-semyonov/DuoLikeAnimation

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects