Live Photos can only be created on the iPhone 6s and 6s Plus, right? Using private APIs and a bit of reverse-engineering, Genady Okrain demonstrates how to create Live Photos on any iPhone, not just the 6s. Join the creator of Parties for WWDC for some live private API fun.
Hi everyone, my name is Genady, and I recently experimented with “hacking” Live Photos — reverse-engineering them to display and work on any iPhone, not just the iPhone 6s.
What are Live Photos? (00:45)
Creating a PHLivePhoto on the iPhone 6 (01:29)
PHLivePhotoView can be used to show Live Photos. Let’s first add a button and a file (the first thing that shows as the Live Photo). We need to import Photos and PhotosUI, and have PHLivePhotoView. We’ll use the video file that I just added to demo this. The Live Photo begins with the middle of the video - I just read this video, find the middle, save the image and run
livePhotoWithImageURL(), which calls a private method. Since that method has 4 parameters, we’ll use an Objective-C header bridge to call the private function using
NSInvocation. Although Live Photos are actually very slow and because they’re not performant, Apple warns in the documentation not to use it on the main thread.
Get more development news like this
We can also create a Live Photo from a video as the iPhone 6s does. The 6s captures a short video with the photo and plays the video when the photo is 3D touched. However, by using this method of creating a
PHLivePhoto and playing it using the
PHLivePhotoView, we can get it to work on any iPhone, such as my regular iPhone 6.
About the content
This content has been published here with the express permission of the author.