swift - Use UIView.animateWithDuration inside protocol -
how can use uiview.animatewithduration inside swift protocol? when try use get:
ambiguous reference member 'animatewithduration(_:delay:options:animations:completion:)'
how can reference uiview (animatewithduration
static method understand)?
since can not provide implementation inside protocol declaration itself, should reference uiview
class inside default implementation. hope 1 of 3 template cases need:
import uikit protocol someprotocol { static func animatewithduration(duration: nstimeinterval, delay: nstimeinterval, options: uiviewanimationoptions, animations: () -> void, completion: ((bool) -> void)?) func animatewithduration(duration: nstimeinterval, delay: nstimeinterval, options: uiviewanimationoptions, animations: () -> void, completion: ((bool) -> void)?) func somecustomfuncforanimate() } extension someprotocol { static func animatewithduration(duration: nstimeinterval, delay: nstimeinterval, options: uiviewanimationoptions, animations: () -> void, completion: ((bool) -> void)?) { uiview.animatewithduration(duration, delay: delay, options: options, animations: animations, completion: completion) } func animatewithduration(duration: nstimeinterval, delay: nstimeinterval, options: uiviewanimationoptions, animations: () -> void, completion: ((bool) -> void)?) { uiview.animatewithduration(duration, delay: delay, options: options, animations: animations, completion: completion) } func somecustomfuncforanimate() { uiview.animatewithduration(0.2, delay: 1, options: .transitioncrossdissolve, animations: {/*...*/}, completion: nil) } }
Comments
Post a Comment