To simplify my lack of this, understand what the word "still" means with non-specific error. I realized that I canβt write a function with arguments to override the extended function, and the compiler gives me such an error, but if I write a simple function without arguments and make a custom implementation and call it with my overridden "simple function" This works :
import Foundation import UIKit extension UIViewController { func slideInView(direction: Direction = Direction.LEFT, duration: CFTimeInterval = 0.5, closure:()->() ) { let animation = CABasicAnimation(keyPath: "transform.translation.x") animation.fromValue = self.view.bounds.width animation.toValue = 0 animation.duration = 0.3 animation.fillMode = kCAFillModeForwards; animation.removedOnCompletion = false UIView.animateWithDuration(0.6, delay: 0.0, options: UIViewAnimationOptions.CurveEaseOut, animations: { self.view!.layer.addAnimation(animation,forKey:nil); }, completion: {(finished) -> () in closure() }); } func slide() { self.slideInView(.LEFT,duration: 0.66) { print("Slide in Left Complete") } } } class OtherUIViewController: UIViewController { override func slide() { self.slideFromBottom(.BOTTOM,duration: 0.66) { print("Slide in Bottom Complete") } } func slideFromBottom(direction: Direction = Direction.BOTTOM, duration: CFTimeInterval = 0.5, closure:()->() ) { let animation = CABasicAnimation(keyPath: "transform.translation.y") animation.fromValue = self.view.bounds.height animation.toValue = 0 animation.duration = 0.3 animation.fillMode = kCAFillModeForwards animation.removedOnCompletion = false UIView.animateWithDuration(0.6, delay: 0.0, options: UIViewAnimationOptions.CurveEaseOut, animations: { self.view!.layer.addAnimation(animation,forKey:nil); }, completion: {(finished) -> () in closure() }); } }
Reduxdj
source share