Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Artur Rymarz artrmz

🎯
Focusing
View GitHub Profile
View TransitionCoordinator.swift
func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {}
View TransitionCoordinator.swift
func navigationController(_ navigationController: UINavigationController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {}
View TransitionAnimator.swift
final class TransitionAnimator: NSObject, UIViewControllerAnimatedTransitioning {
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
}
}
View TransitionAnimator.swift
final class TransitionAnimator: NSObject, UIViewControllerAnimatedTransitioning {
// 1
let presenting: Bool
// 2
init(presenting: Bool) {
self.presenting = presenting
}
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
View TransitionCoordinator.swift
final class TransitionCoordinator: NSObject, UINavigationControllerDelegate {
// 1
var interactionController: UIPercentDrivenInteractiveTransition?
// 2
func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
switch operation {
case .push:
return TransitionAnimator(presenting: true)
case .pop:
View UINavigationController.swift
extension UINavigationController {
// 1
static private var coordinatorHelperKey = "UINavigationController.TransitionCoordinatorHelper"
// 2
var transitionCoordinatorHelper: TransitionCoordinator? {
return objc_getAssociatedObject(self, &UINavigationController.coordinatorHelperKey) as? TransitionCoordinator
}
func addCustomTransitioning() {
View CoreData.swift
private func saveSomeArticles() {
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
return
}
}
View CoreData.swift
private func saveSomeArticles() {
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
return
}
// 1
let context = appDelegate.persistentContainer.viewContext
// 2
let mediumArticle = Article(context: context)
View CoreData.swift
private func loadArticles() -> [Article] {
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
return []
}
let context = appDelegate.persistentContainer.viewContext
// 1
let request: NSFetchRequest<Article> = Article.fetchRequest()
View CoreData.swift
private func deleteAllArticles() {
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
return
}
let context = appDelegate.persistentContainer.viewContext
// 1
let articles = loadArticles()
You can’t perform that action at this time.