Update to Swift 4 and Xcode 9
This commit is contained in:
parent
9e158c1a30
commit
50a9851d55
|
@ -122,12 +122,12 @@
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
LastSwiftUpdateCheck = 0700;
|
LastSwiftUpdateCheck = 0700;
|
||||||
LastUpgradeCheck = 0820;
|
LastUpgradeCheck = 0900;
|
||||||
ORGANIZATIONNAME = "Kaishin & Co";
|
ORGANIZATIONNAME = "Kaishin & Co";
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
9D98823619BC69CA00B790C6 = {
|
9D98823619BC69CA00B790C6 = {
|
||||||
CreatedOnToolsVersion = 6.0;
|
CreatedOnToolsVersion = 6.0;
|
||||||
LastSwiftMigration = 0800;
|
LastSwiftMigration = 0900;
|
||||||
ProvisioningStyle = Manual;
|
ProvisioningStyle = Manual;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -187,14 +187,20 @@
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CLANG_ENABLE_OBJC_ARC = YES;
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
CLANG_WARN_EMPTY_BODY = YES;
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
CLANG_WARN_INT_CONVERSION = YES;
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
@ -233,14 +239,20 @@
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CLANG_ENABLE_OBJC_ARC = YES;
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
CLANG_WARN_EMPTY_BODY = YES;
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
CLANG_WARN_INT_CONVERSION = YES;
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
@ -273,7 +285,8 @@
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = co.kaishin.gifu.demo;
|
PRODUCT_BUNDLE_IDENTIFIER = co.kaishin.gifu.demo;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_VERSION = 3.0;
|
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
|
||||||
|
SWIFT_VERSION = 4.0;
|
||||||
TARGETED_DEVICE_FAMILY = 1;
|
TARGETED_DEVICE_FAMILY = 1;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
|
@ -289,7 +302,8 @@
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = co.kaishin.gifu.demo;
|
PRODUCT_BUNDLE_IDENTIFIER = co.kaishin.gifu.demo;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||||
SWIFT_VERSION = 3.0;
|
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
|
||||||
|
SWIFT_VERSION = 4.0;
|
||||||
TARGETED_DEVICE_FAMILY = 1;
|
TARGETED_DEVICE_FAMILY = 1;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
|
|
|
@ -220,16 +220,16 @@
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
LastSwiftUpdateCheck = 0700;
|
LastSwiftUpdateCheck = 0700;
|
||||||
LastUpgradeCheck = 0830;
|
LastUpgradeCheck = 0900;
|
||||||
ORGANIZATIONNAME = "Kaishin & Co";
|
ORGANIZATIONNAME = "Kaishin & Co";
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
009BD1351BBC7F6500FC982B = {
|
009BD1351BBC7F6500FC982B = {
|
||||||
CreatedOnToolsVersion = 7.0.1;
|
CreatedOnToolsVersion = 7.0.1;
|
||||||
LastSwiftMigration = 0800;
|
LastSwiftMigration = 0900;
|
||||||
};
|
};
|
||||||
00B8C73D1A364DA400C188E7 = {
|
00B8C73D1A364DA400C188E7 = {
|
||||||
CreatedOnToolsVersion = 6.1.1;
|
CreatedOnToolsVersion = 6.1.1;
|
||||||
LastSwiftMigration = 0800;
|
LastSwiftMigration = 0900;
|
||||||
ProvisioningStyle = Manual;
|
ProvisioningStyle = Manual;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -335,7 +335,8 @@
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = co.kaishin.GifuTests;
|
PRODUCT_BUNDLE_IDENTIFIER = co.kaishin.GifuTests;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_VERSION = 3.0;
|
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||||
|
SWIFT_VERSION = 4.0;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
|
@ -351,7 +352,8 @@
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = co.kaishin.GifuTests;
|
PRODUCT_BUNDLE_IDENTIFIER = co.kaishin.GifuTests;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||||
SWIFT_VERSION = 3.0;
|
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||||
|
SWIFT_VERSION = 4.0;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
@ -363,14 +365,20 @@
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CLANG_ENABLE_OBJC_ARC = YES;
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
CLANG_WARN_EMPTY_BODY = YES;
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
CLANG_WARN_INT_CONVERSION = YES;
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
@ -413,14 +421,20 @@
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CLANG_ENABLE_OBJC_ARC = YES;
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
CLANG_WARN_EMPTY_BODY = YES;
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
CLANG_WARN_INT_CONVERSION = YES;
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
@ -452,6 +466,7 @@
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
APPLICATION_EXTENSION_API_ONLY = YES;
|
APPLICATION_EXTENSION_API_ONLY = YES;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
|
||||||
DEFINES_MODULE = YES;
|
DEFINES_MODULE = YES;
|
||||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||||
DYLIB_CURRENT_VERSION = 1;
|
DYLIB_CURRENT_VERSION = 1;
|
||||||
|
@ -465,7 +480,8 @@
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_VERSION = 3.0;
|
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
|
||||||
|
SWIFT_VERSION = 4.0;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
|
@ -474,6 +490,7 @@
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
APPLICATION_EXTENSION_API_ONLY = YES;
|
APPLICATION_EXTENSION_API_ONLY = YES;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
|
||||||
DEFINES_MODULE = YES;
|
DEFINES_MODULE = YES;
|
||||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||||
DYLIB_CURRENT_VERSION = 1;
|
DYLIB_CURRENT_VERSION = 1;
|
||||||
|
@ -487,7 +504,8 @@
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||||
SWIFT_VERSION = 3.0;
|
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
|
||||||
|
SWIFT_VERSION = 4.0;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "0830"
|
LastUpgradeVersion = "0900"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
@ -40,6 +40,7 @@
|
||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
language = ""
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
<Testables>
|
<Testables>
|
||||||
<TestableReference
|
<TestableReference
|
||||||
|
@ -69,6 +70,7 @@
|
||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
language = ""
|
||||||
launchStyle = "0"
|
launchStyle = "0"
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
|
|
@ -15,7 +15,7 @@ struct AnimatedFrame {
|
||||||
|
|
||||||
/// Whether this frame instance contains an image or not.
|
/// Whether this frame instance contains an image or not.
|
||||||
var isPlaceholder: Bool {
|
var isPlaceholder: Bool {
|
||||||
return image == .none
|
return image == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a new instance from an ptional image.
|
/// Returns a new instance from an ptional image.
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class Animator {
|
||||||
/// - parameter contentMode: The view content mode to use for the individual frames.
|
/// - parameter contentMode: The view content mode to use for the individual frames.
|
||||||
/// - parameter loopCount: Desired number of loops, <= 0 for infinite loop.
|
/// - parameter loopCount: Desired number of loops, <= 0 for infinite loop.
|
||||||
/// - parameter completionHandler: Completion callback function
|
/// - parameter completionHandler: Completion callback function
|
||||||
func prepareForAnimation(withGIFNamed imageName: String, size: CGSize, contentMode: UIViewContentMode, loopCount: Int = 0, completionHandler: ((Void) -> Void)? = .none) {
|
func prepareForAnimation(withGIFNamed imageName: String, size: CGSize, contentMode: UIViewContentMode, loopCount: Int = 0, completionHandler: (() -> Void)? = nil) {
|
||||||
guard let extensionRemoved = imageName.components(separatedBy: ".")[safe: 0],
|
guard let extensionRemoved = imageName.components(separatedBy: ".")[safe: 0],
|
||||||
let imagePath = Bundle.main.url(forResource: extensionRemoved, withExtension: "gif"),
|
let imagePath = Bundle.main.url(forResource: extensionRemoved, withExtension: "gif"),
|
||||||
let data = try? Data(contentsOf: imagePath) else { return }
|
let data = try? Data(contentsOf: imagePath) else { return }
|
||||||
|
@ -83,7 +83,7 @@ public class Animator {
|
||||||
/// - parameter contentMode: The view content mode to use for the individual frames.
|
/// - parameter contentMode: The view content mode to use for the individual frames.
|
||||||
/// - parameter loopCount: Desired number of loops, <= 0 for infinite loop.
|
/// - parameter loopCount: Desired number of loops, <= 0 for infinite loop.
|
||||||
/// - parameter completionHandler: Completion callback function
|
/// - parameter completionHandler: Completion callback function
|
||||||
func prepareForAnimation(withGIFData imageData: Data, size: CGSize, contentMode: UIViewContentMode, loopCount: Int = 0, completionHandler: ((Void) -> Void)? = .none) {
|
func prepareForAnimation(withGIFData imageData: Data, size: CGSize, contentMode: UIViewContentMode, loopCount: Int = 0, completionHandler: (() -> Void)? = nil) {
|
||||||
frameStore = FrameStore(data: imageData, size: size, contentMode: contentMode, framePreloadCount: frameBufferCount, loopCount: loopCount)
|
frameStore = FrameStore(data: imageData, size: size, contentMode: contentMode, framePreloadCount: frameBufferCount, loopCount: loopCount)
|
||||||
frameStore?.shouldResizeFrames = shouldResizeFrames
|
frameStore?.shouldResizeFrames = shouldResizeFrames
|
||||||
frameStore?.prepareFrames(completionHandler)
|
frameStore?.prepareFrames(completionHandler)
|
||||||
|
|
|
@ -93,7 +93,7 @@ class FrameStore {
|
||||||
|
|
||||||
// MARK: - Frames
|
// MARK: - Frames
|
||||||
/// Loads the frames from an image source, resizes them, then caches them in `animatedFrames`.
|
/// Loads the frames from an image source, resizes them, then caches them in `animatedFrames`.
|
||||||
func prepareFrames(_ completionHandler: ((Void) -> Void)? = .none) {
|
func prepareFrames(_ completionHandler: (() -> Void)? = nil) {
|
||||||
frameCount = Int(CGImageSourceGetCount(imageSource))
|
frameCount = Int(CGImageSourceGetCount(imageSource))
|
||||||
animatedFrames.reserveCapacity(frameCount)
|
animatedFrames.reserveCapacity(frameCount)
|
||||||
preloadFrameQueue.async {
|
preloadFrameQueue.async {
|
||||||
|
@ -115,7 +115,7 @@ class FrameStore {
|
||||||
/// - parameter index: The index of the duration.
|
/// - parameter index: The index of the duration.
|
||||||
/// - returns: The duration of the given frame.
|
/// - returns: The duration of the given frame.
|
||||||
func duration(at index: Int) -> TimeInterval {
|
func duration(at index: Int) -> TimeInterval {
|
||||||
return animatedFrames[safe: index]?.duration ?? TimeInterval.infinity
|
return animatedFrames[safe: index]?.duration ?? TimeInterval.infinity
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks whether the frame should be changed and calls a handler with the results.
|
/// Checks whether the frame should be changed and calls a handler with the results.
|
||||||
|
@ -146,7 +146,7 @@ private extension FrameStore {
|
||||||
/// - parameter index: The index of the frame to load.
|
/// - parameter index: The index of the frame to load.
|
||||||
/// - returns: An optional `UIImage` instance.
|
/// - returns: An optional `UIImage` instance.
|
||||||
func loadFrame(at index: Int) -> UIImage? {
|
func loadFrame(at index: Int) -> UIImage? {
|
||||||
guard let imageRef = CGImageSourceCreateImageAtIndex(imageSource, index, nil) else { return .none }
|
guard let imageRef = CGImageSourceCreateImageAtIndex(imageSource, index, nil) else { return nil }
|
||||||
let image = UIImage(cgImage: imageRef)
|
let image = UIImage(cgImage: imageRef)
|
||||||
let scaledImage: UIImage?
|
let scaledImage: UIImage?
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ private extension FrameStore {
|
||||||
(0..<frameCount).forEach { index in
|
(0..<frameCount).forEach { index in
|
||||||
let frameDuration = CGImageFrameDuration(with: imageSource, atIndex: index)
|
let frameDuration = CGImageFrameDuration(with: imageSource, atIndex: index)
|
||||||
duration += min(frameDuration, maxTimeStep)
|
duration += min(frameDuration, maxTimeStep)
|
||||||
animatedFrames += [AnimatedFrame(image: .none, duration: frameDuration)]
|
animatedFrames += [AnimatedFrame(image: nil, duration: frameDuration)]
|
||||||
|
|
||||||
if index > bufferFrameCount { return }
|
if index > bufferFrameCount { return }
|
||||||
animatedFrames[index] = animatedFrames[index].makeAnimatedFrame(with: loadFrame(at: index))
|
animatedFrames[index] = animatedFrames[index].makeAnimatedFrame(with: loadFrame(at: index))
|
||||||
|
|
|
@ -69,7 +69,7 @@ extension GIFAnimatable {
|
||||||
///
|
///
|
||||||
/// - parameter imageName: The file name of the GIF in the main bundle.
|
/// - parameter imageName: The file name of the GIF in the main bundle.
|
||||||
/// - parameter loopCount: Desired number of loops, <= 0 for infinite loop.
|
/// - parameter loopCount: Desired number of loops, <= 0 for infinite loop.
|
||||||
public func prepareForAnimation(withGIFNamed imageName: String, loopCount: Int = 0, completionHandler: ((Void) -> Void)? = .none) {
|
public func prepareForAnimation(withGIFNamed imageName: String, loopCount: Int = 0, completionHandler: (() -> Void)? = nil) {
|
||||||
animator?.prepareForAnimation(withGIFNamed: imageName, size: frame.size, contentMode: contentMode, loopCount: loopCount, completionHandler: completionHandler)
|
animator?.prepareForAnimation(withGIFNamed: imageName, size: frame.size, contentMode: contentMode, loopCount: loopCount, completionHandler: completionHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ extension GIFAnimatable {
|
||||||
///
|
///
|
||||||
/// - parameter imageData: GIF image data.
|
/// - parameter imageData: GIF image data.
|
||||||
/// - parameter loopCount: Desired number of loops, <= 0 for infinite loop.
|
/// - parameter loopCount: Desired number of loops, <= 0 for infinite loop.
|
||||||
public func prepareForAnimation(withGIFData imageData: Data, loopCount: Int = 0, completionHandler: ((Void) -> Void)? = .none) {
|
public func prepareForAnimation(withGIFData imageData: Data, loopCount: Int = 0, completionHandler: (() -> Void)? = nil) {
|
||||||
if var imageContainer = self as? ImageContainer {
|
if var imageContainer = self as? ImageContainer {
|
||||||
imageContainer.image = UIImage(data: imageData)
|
imageContainer.image = UIImage(data: imageData)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
extension Array {
|
extension Array {
|
||||||
subscript(safe index: Int) -> Element? {
|
subscript(safe index: Int) -> Element? {
|
||||||
return indices ~= index ? self[index] : .none
|
return indices ~= index ? self[index] : nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ func CGImageFrameDuration(with imageSource: CGImageSource, atIndex index: Int) -
|
||||||
///
|
///
|
||||||
/// - returns: A capped frame duration.
|
/// - returns: A capped frame duration.
|
||||||
func capDuration(with duration: Double) -> Double? {
|
func capDuration(with duration: Double) -> Double? {
|
||||||
if duration < 0 { return .none }
|
if duration < 0 { return nil }
|
||||||
let threshold = 0.02 - Double.ulpOfOne
|
let threshold = 0.02 - Double.ulpOfOne
|
||||||
let cappedDuration = duration < threshold ? 0.1 : duration
|
let cappedDuration = duration < threshold ? 0.1 : duration
|
||||||
return cappedDuration
|
return cappedDuration
|
||||||
|
@ -35,7 +35,7 @@ func capDuration(with duration: Double) -> Double? {
|
||||||
func frameDuration(with properties: GIFProperties) -> Double? {
|
func frameDuration(with properties: GIFProperties) -> Double? {
|
||||||
guard let unclampedDelayTime = properties[String(kCGImagePropertyGIFUnclampedDelayTime)],
|
guard let unclampedDelayTime = properties[String(kCGImagePropertyGIFUnclampedDelayTime)],
|
||||||
let delayTime = properties[String(kCGImagePropertyGIFDelayTime)]
|
let delayTime = properties[String(kCGImagePropertyGIFDelayTime)]
|
||||||
else { return .none }
|
else { return nil }
|
||||||
|
|
||||||
return duration(withUnclampedTime: unclampedDelayTime, andClampedTime: delayTime)
|
return duration(withUnclampedTime: unclampedDelayTime, andClampedTime: delayTime)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>126</string>
|
<string>128</string>
|
||||||
<key>NSPrincipalClass</key>
|
<key>NSPrincipalClass</key>
|
||||||
<string></string>
|
<string></string>
|
||||||
</dict>
|
</dict>
|
||||||
|
|
Loading…
Reference in New Issue