This is a demo that mimics the screensaver program on the Apple retail store prototype. Tap the picture to see the video.
Now it has a new animation!!! You can watch airpods.mov for detail.
- Xcode 11 and later
- iOS 12 and later
- Swift 4.2 and later
If you want to run this project on your iPhone, you have to prepare for a Mac and have Xcode installed.
There is no special way to use it. If you don't want to play with your phone, you can open this app and enjoy the animation. It's also easy to exit the animation, press the home button (if your device is iPhone 8 and below) or swipe to exit the background (if your device is iPhone X and above). Of course, I offer an easier way, as long as your phone has a large swing, the software will return to the main screen, similar to the prototype of the Apple retail store.
If you want to customize some parameters, you can modify some of the following parameters in the program.
If you think the program monitoring device is not very sensitive, you can make it more sensitive by modifying the value of ds.
func testMotion() {
if motionManager.isDeviceMotionAvailable {
// 设置0.4是为了监测细微摇动
let ds: Float = 0.4
motionManager.deviceMotionUpdateInterval = 0.1
motionManager.startDeviceMotionUpdates(to: queue, withHandler: { (motion: CMDeviceMotion?, error: Error?) -> Void in
if let motion = motion {
let userAcc = motion.userAcceleration
if fabsf(Float(userAcc.x)) > ds || fabsf(Float(userAcc.y)) > ds || fabsf(Float(userAcc.z)) > ds {
DispatchQueue.main.async {
// 退出程序返回后台的方法
UIControl().sendAction(#selector(NSXPCConnection.suspend), to: UIApplication.shared, for: nil)
}
}
}
})
}
}
If you want to switch to another video, you can modify the incoming video name to achieve the goal.
if UIDevice.current.userInterfaceIdiom == .pad {
filePath = Bundle.main.path(forResource: "3", ofType: "mov")
} else if UIDevice.current.userInterfaceIdiom == .phone {
filePath = Bundle.main.path(forResource: "6", ofType: "mov")
}
ScreenSaver is available under the MIT license.