Transitions ports from GL-Transitions to Metal.
Support Following Transitions:
MTTransitions is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod MTTransitions
Each transition requires two input MTIImage
. Image should be .oriented(.downMirrored)
.
import MTTransitions
let transition = MTBounceTransition()
transition.inputImage = <from Image>
transition.destImage = <to Image>
// animate progress from 0.0 to 1.0
imageView.image = transition.outputImage
let effect = MTPerlinTransition()
MTTransition.transition(with: view, effect: effect, animations: {
// Do your animation to your view
}) { (_) in
// Transition completed
}
class PushAViewController: UIViewController {
private let transition = MTViewControllerTransition(transition: MTBurnTransition())
// ...
}
extension PushAViewController: UINavigationControllerDelegate {
func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
if operation == .push {
return transition
}
return nil
}
}
class PresentAViewController: UIViewController {
// ...
let vc = PresentBViewController()
vc.modalPresentationStyle = .fullScreen
vc.transitioningDelegate = self
present(vc, animated: true, completion: nil)
}
extension PresentAViewController: UIViewControllerTransitioningDelegate {
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return transtion
}
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return transtion
}
}
MTTransitions
also support merging videos with transitions.
// pick one transtion effect
let effect = MTTransition.Effect.wipeLeft
let duration = CMTimeMakeWithSeconds(2.0, preferredTimescale: 1000)
try? videoTransition.merge(clips,
effect: effect,
transitionDuration: duration) { [weak self] result in
guard let self = self else { return }
let playerItem = AVPlayerItem(asset: result.composition)
playerItem.videoComposition = result.videoComposition
self.player.seek(to: .zero)
self.player.replaceCurrentItem(with: playerItem)
self.player.play()
}
Please refer VideoTransitionSampleViewController
and MultipleVideoTransitionsViewController
for more details.
MTMovieMaker
support create video from a sequence images with transitions. You can also pass a local audio file url to MTMovieMaker
to create background music.
let fileURL = URL(fileURLWithPath: path)
movieMaker = MTMovieMaker(outputURL: fileURL)
do {
try MTMovieMaker?.createVideo(with: images, effects: effects) { result in
switch result {
case .success(let url):
print(url)
case .failure(let error):
print(error)
}
}
} catch {
print(error)
}
link |
Stars: 206 |
Last commit: 5 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics