diff --git a/EFCountingLabel/Classes/EFCount.swift b/EFCountingLabel/Classes/EFCount.swift index 3e3e166..dbb9f3b 100644 --- a/EFCountingLabel/Classes/EFCount.swift +++ b/EFCountingLabel/Classes/EFCount.swift @@ -17,6 +17,7 @@ // THE SOFTWARE. import Foundation +import QuartzCore public protocol EFTiming { func update(_ time: CGFloat) -> CGFloat diff --git a/EFCountingLabel/Classes/EFCountAdapter.swift b/EFCountingLabel/Classes/EFCountAdapter.swift index 56417cf..e7b416f 100644 --- a/EFCountingLabel/Classes/EFCountAdapter.swift +++ b/EFCountingLabel/Classes/EFCountAdapter.swift @@ -59,6 +59,46 @@ extension EFCountAdapter { open class EFCountingButton: UIButton, EFCountAdapter { public private(set) var counter = EFCounter() + + open var formatBlock: ((CGFloat) -> String)? { + set { + if let formatBlock = newValue { + setUpdateBlock { value, button in button.setTitle(formatBlock(value), for: .normal) } + } else { + setUpdateBlock(nil) + } + } + @available(*, unavailable) + get { + return nil + } + } + open var attributedFormatBlock: ((CGFloat) -> NSAttributedString)? { + set { + if let attributedFormatBlock = newValue { + setUpdateBlock { value, button in button.setAttributedTitle(attributedFormatBlock(value), for: .normal) } + } else { + setUpdateBlock(nil) + } + } + @available(*, unavailable) + get { + return nil + } + } + open var completionBlock: (() -> Void)? { + set { + if let completionBlock = newValue { + setCompletionBlock { _ in completionBlock() } + } else { + setCompletionBlock(nil) + } + } + @available(*, unavailable) + get { + return nil + } + } deinit { counter.invalidate() @@ -68,6 +108,46 @@ open class EFCountingButton: UIButton, EFCountAdapter { open class EFCountingLabel: UILabel, EFCountAdapter { public private(set) var counter = EFCounter() + open var formatBlock: ((CGFloat) -> String)? { + set { + if let formatBlock = newValue { + setUpdateBlock { value, label in label.text = formatBlock(value) } + } else { + setUpdateBlock(nil) + } + } + @available(*, unavailable) + get { + return nil + } + } + open var attributedFormatBlock: ((CGFloat) -> NSAttributedString)? { + set { + if let attributedFormatBlock = newValue { + setUpdateBlock { value, label in label.attributedText = attributedFormatBlock(value) } + } else { + setUpdateBlock(nil) + } + } + @available(*, unavailable) + get { + return nil + } + } + open var completionBlock: (() -> Void)? { + set { + if let completionBlock = newValue { + setCompletionBlock { _ in completionBlock() } + } else { + setCompletionBlock(nil) + } + } + @available(*, unavailable) + get { + return nil + } + } + deinit { counter.invalidate() } diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 50e94a9..4869f88 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -13,4 +13,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 18006cf8308f1ddc4db21317a6cf556416d587b1 -COCOAPODS: 1.7.0.rc.1 +COCOAPODS: 1.7.0 diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index 50e94a9..4869f88 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -13,4 +13,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 18006cf8308f1ddc4db21317a6cf556416d587b1 -COCOAPODS: 1.7.0.rc.1 +COCOAPODS: 1.7.0 diff --git a/Example/Pods/Target Support Files/Pods-EFCountingLabel_Example/Pods-EFCountingLabel_Example-frameworks.sh b/Example/Pods/Target Support Files/Pods-EFCountingLabel_Example/Pods-EFCountingLabel_Example-frameworks.sh index 777ef1a..b878448 100755 --- a/Example/Pods/Target Support Files/Pods-EFCountingLabel_Example/Pods-EFCountingLabel_Example-frameworks.sh +++ b/Example/Pods/Target Support Files/Pods-EFCountingLabel_Example/Pods-EFCountingLabel_Example-frameworks.sh @@ -94,7 +94,7 @@ install_dsym() { binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}" # Strip invalid architectures so "fat" simulator / device frameworks work on device - if [[ "$(file "$binary")" == *"Mach-O dSYM companion"* ]]; then + if [[ "$(file "$binary")" == *"Mach-O "*"dSYM companion"* ]]; then strip_invalid_archs "$binary" fi