Files
Ents-mirror/Ents/Classes/utils/NoImplicitAnimationBlock.swift
2019-03-15 09:38:33 +02:00

28 lines
769 B
Swift

//
// NoImplicitAnimationBlock.swift
// Ents
//
// Created by Georges Boumis on 06/09/2016.
// Copyright © 2016-2019 Georges Boumis.
// Licensed under MIT (https://github.com/averello/Ents/blob/master/LICENSE)
//
import Foundation
#if canImport(QuartzCore) && canImport(CoreFoundation)
import QuartzCore
import CoreFoundation
public func NoImplicitAnimation(_ block: () throws -> Void) rethrows {
CATransaction.begin(); defer { CATransaction.commit() }
CATransaction.setDisableActions(true)
try block()
}
public func ImplicitAnimation(withDuration duration: CFTimeInterval, _ block: () throws -> Void) rethrows {
CATransaction.begin(); defer { CATransaction.commit() }
CATransaction.setAnimationDuration(duration)
try block()
}
#endif