我有一些viewcontroller类,我想要覆盖以下方法:
open func doneButton(barButtonItem: UIBarButtonItem) {
if let somevalue = someValueInTheCode {
dismiss(animated: true, completion: nil)
callback(somevalue )
}
}
我想在子类中实现动画:
internal func animate( _ cb: @escaping () -> ()) {
if animating {
return
}
self.animating = true
UIView.animate(withDuration: C.animTimeNav / 2.0, animations: { [weak self] in
self?.navigationController?.navigationBar.barTintColor = C.animNavColor
self?.navigationController?.navigationBar.layoutIfNeeded()
},completion: { _ in
UIView.animate(withDuration: C.animTimeNav / 1.0, animations: { [weak self] in
self?.navigationController?.navigationBar.barTintColor = C.navigationBarColor
self?.navigationController?.navigationBar.layoutIfNeeded()
},completion: { [weak self] _ in
self?.animating = false
cb()
})
})
}
所以,我想要这个新的重写方法:
open override func doneButton(barButtonItem: UIBarButtonItem) {
animate {[weak barButtonItem] in
super.doneButton(barButtonItem: barButtonItem ?? UIBarButtonItem())
}
}
我的问题是:
super
?