CALayerExtension.swift 413 B

1234567891011121314151617
  1. //
  2. // Created by Jake Lin on 2/23/16.
  3. // Copyright © 2016 IBAnimatable. All rights reserved.
  4. //
  5. import UIKit
  6. public extension CALayer {
  7. class func animate(_ animation: AnimatableExecution, completion: AnimatableCompletion? = nil) {
  8. CATransaction.begin()
  9. if let completion = completion {
  10. CATransaction.setCompletionBlock { completion() }
  11. }
  12. animation()
  13. CATransaction.commit()
  14. }
  15. }