Custom Push and Pop animation
- Support all directions :)
- left, right, up, down, snapshot
public enum NavigationAnimationType: Int {
case none = 0
case left
case right
case up
case down
case snapShot
}
protocol NavigationAnimatorAble {
var pushAnimation: PushAnimator? { get }
var popAnimation: PopAnimator? { get }
}
- Confirm to
NavigationAnimatorAble
protocol - Implement push & pop animator like below
extension RightViewController: NavigationAnimatorAble {
var pushAnimation: PushAnimator? {
return PushAnimator(animationType:.right)
}
var popAnimation: PopAnimator? {
return self.popAnimator
}
}
extension SnapShotViewController: NavigationAnimatorAble {
var pushAnimation: PushAnimator? {
return PushAnimator(animationType: .snapShot)
}
var popAnimation: PopAnimator? {
return PopAnimator(animationType: .none)
}
}
let snapShotView = SnapShotView(view: fromViewController.view, shadows: .right)
struct ShadowDirection: OptionSet {
let rawValue: Int
static let left = ShadowDirection(rawValue: 1 << 0)
static let right = ShadowDirection(rawValue: 1 << 1)
static let up = ShadowDirection(rawValue: 1 << 2)
static let down = ShadowDirection(rawValue: 1 << 3)
static let none = ShadowDirection(rawValue: 1 << 4)
static let all: ShadowDirection = [.left, .right, .up, .down]
}