Moving view transition with the blurring effect between view controllers for Swift3
Moving view transition with the blurring effect between view controllers for Swift3
This code style is the Protocol Oriented Programming
.
So you donβt need to inherit. Just Implement protocols.
You can handle some parameter to customize this transition. e.g. scale, duration, etc.
Add the following to your Podfile
.
pod "URMovingTransitionAnimator"
See the Example
folder.
Run pod install
and open the .xcworkspace file.
import URMovingTransitionAnimator
class viewController: UIViewController, URMovingTransitionMakable {
...
override func viewDidLoad() {
super.viewDidload()
self.initMovingTrasitionGesture()
...
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.initMovingTransitionNavigationDelegate()
...
}
deinit {
self.removeMovingTransitionGesture()
...
}
...
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
...
if let cell = tableView.cellForRow(at: indexPath) as? URExampleTableViewCell {
self.makeBlurredTransitionAnimator(target: cell.imgView, baseOn: tableView.superview!, duration: 0.8)
// if you want to add scaling animation, use makeTransitionAnimator function like below
// At the beginning, the scaling animation will be showed!!
// self.makeBlurredTransitionAnimator(target: cell.imgView, baseOn: tableView.superview!, duration: 0.8, needScaleEffect: true, scale: 1.05)
// if you want to transition without the blur effect, you can use this make function!!
// self.makeTransitionAnimator(target: cell.imgView, baseOn: tableView.superview!, duration: 0.8, needScaleEffect: true, scale: 1.05)
}
...
// push view controller
}
...
}
class finishViewController: UIViewController, URMovingTransitionReceivable {
...
var transitionView: UIView?
...
func transitionFinishingFrame(startingFrame: CGRect) -> CGRect {
let frame = {view's frame to be the destination}
let finishingFrame = CGRect(origin: CGPoint(x: 0, y: 64), size: frame.size)
return finishingFrame
}
...
}
URMovingTransitionAnimator is available under the MIT license. See the LICENSE file for more info.