Skip to content

Instantly share code, notes, and snippets.

@xhinking
Created March 23, 2016 04:55
Show Gist options
  • Save xhinking/e5e1a8fb751d71dcd932 to your computer and use it in GitHub Desktop.
Save xhinking/e5e1a8fb751d71dcd932 to your computer and use it in GitHub Desktop.
public func Init<Type>(value: Type, @noescape block: (object: Type) -> Void) -> Type {
block(object: value)
return value
}
let fade = Init(CABasicAnimation(keyPath: "opacity")) {
$0.duration = NSTimeInterval(duration)
$0.fromValue = fromOpacity
$0.toValue = toOpacity
$0.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
$0.fillMode = kCAFillModeForwards
$0.removedOnCompletion = false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment