diff --git a/.tailor.yml b/.tailor.yml new file mode 100644 index 0000000..362ae67 --- /dev/null +++ b/.tailor.yml @@ -0,0 +1,4 @@ +exclude: + - 'Pods' + - 'Carthage' + - 'LTMorphingLabelDemo' diff --git a/LTMorphingLabel/LTCharacterLimbo.swift b/LTMorphingLabel/LTCharacterLimbo.swift index 8571313..2ddfc45 100644 --- a/LTMorphingLabel/LTCharacterLimbo.swift +++ b/LTMorphingLabel/LTCharacterLimbo.swift @@ -28,7 +28,7 @@ import UIKit -public struct LTCharacterLimbo : CustomDebugStringConvertible { +public struct LTCharacterLimbo: CustomDebugStringConvertible { public let char: Character public var rect: CGRect diff --git a/LTMorphingLabel/LTEasing.swift b/LTMorphingLabel/LTEasing.swift index 18430f4..5da4a58 100644 --- a/LTMorphingLabel/LTEasing.swift +++ b/LTMorphingLabel/LTEasing.swift @@ -50,4 +50,5 @@ public struct LTEasing { } }(t / d) } + } diff --git a/LTMorphingLabel/LTEmitterView.swift b/LTMorphingLabel/LTEmitterView.swift index d63d3ce..d278689 100644 --- a/LTMorphingLabel/LTEmitterView.swift +++ b/LTMorphingLabel/LTEmitterView.swift @@ -68,8 +68,10 @@ public struct LTEmitter { image = UIImage(named: particleName) + if image != nil { + return + } // Load from Framework - if image != nil { return } image = UIImage( named: particleName, inBundle: NSBundle(forClass: LTMorphingLabel.self), diff --git a/LTMorphingLabel/LTMorphingEffect.swift b/LTMorphingLabel/LTMorphingEffect.swift index 52e085e..9f21b64 100644 --- a/LTMorphingLabel/LTMorphingEffect.swift +++ b/LTMorphingLabel/LTMorphingEffect.swift @@ -28,7 +28,7 @@ import UIKit -@objc public enum LTMorphingEffect : Int, CustomStringConvertible { +@objc public enum LTMorphingEffect: Int, CustomStringConvertible { case Scale = 0 case Evaporate @@ -60,4 +60,5 @@ import UIKit return "Scale" } } + } diff --git a/LTMorphingLabel/LTMorphingLabel+Anvil.swift b/LTMorphingLabel/LTMorphingLabel+Anvil.swift index 82d2329..b6d3cf5 100644 --- a/LTMorphingLabel/LTMorphingLabel+Anvil.swift +++ b/LTMorphingLabel/LTMorphingLabel+Anvil.swift @@ -179,7 +179,7 @@ extension LTMorphingLabel { } effectClosures["Anvil\(phaseDisappear)"] = { - (char:Character, index: Int, progress: Float) in + char, index, progress in return LTCharacterLimbo( char: char, @@ -190,7 +190,7 @@ extension LTMorphingLabel { } effectClosures["Anvil\(phaseAppear)"] = { - (char:Character, index: Int, progress: Float) in + char, index, progress in var rect = self.newRects[index] diff --git a/LTMorphingLabel/LTMorphingLabel+Burn.swift b/LTMorphingLabel/LTMorphingLabel+Burn.swift index 4a790e9..a3df14d 100644 --- a/LTMorphingLabel/LTMorphingLabel+Burn.swift +++ b/LTMorphingLabel/LTMorphingLabel+Burn.swift @@ -72,7 +72,7 @@ extension LTMorphingLabel { } progressClosures["Burn\(phaseProgress)"] = { - (index: Int, progress: Float, isNewChar: Bool) in + index, progress, isNewChar in if !isNewChar { return min(1.0, max(0.0, progress)) @@ -84,7 +84,7 @@ extension LTMorphingLabel { } effectClosures["Burn\(phaseDisappear)"] = { - (char:Character, index: Int, progress: Float) in + char, index, progress in return LTCharacterLimbo( char: char, @@ -96,7 +96,7 @@ extension LTMorphingLabel { } effectClosures["Burn\(phaseAppear)"] = { - (char:Character, index: Int, progress: Float) in + char, index, progress in if char != " " { let rect = self.newRects[index] diff --git a/LTMorphingLabel/LTMorphingLabel+Evaporate.swift b/LTMorphingLabel/LTMorphingLabel+Evaporate.swift index df738ac..911812c 100644 --- a/LTMorphingLabel/LTMorphingLabel+Evaporate.swift +++ b/LTMorphingLabel/LTMorphingLabel+Evaporate.swift @@ -40,7 +40,7 @@ extension LTMorphingLabel { } effectClosures["Evaporate\(phaseDisappear)"] = { - (char:Character, index: Int, progress: Float) in + char, index, progress in let newProgress = LTEasing.easeOutQuint(progress, 0.0, 1.0, 1.0) let yOffset: CGFloat = -0.8 * CGFloat(self.font.pointSize) * CGFloat(newProgress) @@ -56,7 +56,7 @@ extension LTMorphingLabel { } effectClosures["Evaporate\(phaseAppear)"] = { - (char:Character, index: Int, progress: Float) in + char, index, progress in let newProgress = 1.0 - LTEasing.easeOutQuint(progress, 0.0, 1.0) let yOffset = CGFloat(self.font.pointSize) * CGFloat(newProgress) * 1.2 diff --git a/LTMorphingLabel/LTMorphingLabel+Fall.swift b/LTMorphingLabel/LTMorphingLabel+Fall.swift index 5372ee0..8f48eb9 100644 --- a/LTMorphingLabel/LTMorphingLabel+Fall.swift +++ b/LTMorphingLabel/LTMorphingLabel+Fall.swift @@ -54,7 +54,7 @@ extension LTMorphingLabel { } effectClosures["Fall\(phaseDisappear)"] = { - (char:Character, index: Int, progress: Float) in + char, index, progress in return LTCharacterLimbo( char: char, @@ -65,7 +65,7 @@ extension LTMorphingLabel { } effectClosures["Fall\(phaseAppear)"] = { - (char:Character, index: Int, progress: Float) in + char, index, progress in let currentFontSize = CGFloat( LTEasing.easeOutQuint(progress, 0.0, Float(self.font.pointSize)) @@ -83,21 +83,21 @@ extension LTMorphingLabel { drawingClosures["Fall\(phaseDraw)"] = { - (charLimbo: LTCharacterLimbo) in + limbo in - if charLimbo.drawingProgress > 0.0 { + if limbo.drawingProgress > 0.0 { let context = UIGraphicsGetCurrentContext() - var charRect = charLimbo.rect + var charRect = limbo.rect CGContextSaveGState(context) let charCenterX = charRect.origin.x + (charRect.size.width / 2.0) var charBottomY = charRect.origin.y + charRect.size.height - self.font.pointSize / 6 var charColor = self.textColor // Fall down if drawingProgress is more than 50% - if charLimbo.drawingProgress > 0.5 { + if limbo.drawingProgress > 0.5 { let ease = CGFloat( LTEasing.easeInQuint( - Float(charLimbo.drawingProgress - 0.4), + Float(limbo.drawingProgress - 0.4), 0.0, 1.0, 0.5 @@ -108,7 +108,7 @@ extension LTMorphingLabel { 1.0, max( 0.0, - charLimbo.drawingProgress * -2.0 + 2.0 + 0.01 + limbo.drawingProgress * -2.0 + 2.0 + 0.01 ) ) charColor = self.textColor.colorWithAlphaComponent(fadeOutAlpha) @@ -121,21 +121,21 @@ extension LTMorphingLabel { height: charRect.size.height) CGContextTranslateCTM(context, charCenterX, charBottomY) - let angle = Float(sin(Double(charLimbo.rect.origin.x)) > 0.5 ? 168 : -168) + let angle = Float(sin(Double(limbo.rect.origin.x)) > 0.5 ? 168 : -168) let rotation = CGFloat( LTEasing.easeOutBack( min( 1.0, - Float(charLimbo.drawingProgress) + Float(limbo.drawingProgress) ), 0.0, 1.0 ) * angle ) CGContextRotateCTM(context, rotation * CGFloat(M_PI) / 180.0) - let s = String(charLimbo.char) + let s = String(limbo.char) s.drawInRect(charRect, withAttributes: [ - NSFontAttributeName: self.font.fontWithSize(charLimbo.size), + NSFontAttributeName: self.font.fontWithSize(limbo.size), NSForegroundColorAttributeName: charColor ]) CGContextRestoreGState(context) diff --git a/LTMorphingLabel/LTMorphingLabel+Pixelate.swift b/LTMorphingLabel/LTMorphingLabel+Pixelate.swift index 32a7124..f6c0e1c 100644 --- a/LTMorphingLabel/LTMorphingLabel+Pixelate.swift +++ b/LTMorphingLabel/LTMorphingLabel+Pixelate.swift @@ -33,7 +33,7 @@ extension LTMorphingLabel { func PixelateLoad() { effectClosures["Pixelate\(phaseDisappear)"] = { - (char:Character, index: Int, progress: Float) in + char, index, progress in return LTCharacterLimbo( char: char, @@ -44,7 +44,7 @@ extension LTMorphingLabel { } effectClosures["Pixelate\(phaseAppear)"] = { - (char:Character, index: Int, progress: Float) in + char, index, progress in return LTCharacterLimbo( char: char, @@ -56,16 +56,16 @@ extension LTMorphingLabel { } drawingClosures["Pixelate\(phaseDraw)"] = { - (charLimbo: LTCharacterLimbo) in + limbo in - if charLimbo.drawingProgress > 0.0 { + if limbo.drawingProgress > 0.0 { let charImage = self.pixelateImageForCharLimbo( - charLimbo, - withBlurRadius: charLimbo.drawingProgress * 6.0 + limbo, + withBlurRadius: limbo.drawingProgress * 6.0 ) - charImage.drawInRect(charLimbo.rect) + charImage.drawInRect(limbo.rect) return true } diff --git a/LTMorphingLabel/LTMorphingLabel+Sparkle.swift b/LTMorphingLabel/LTMorphingLabel+Sparkle.swift index 7db4324..7f64b64 100644 --- a/LTMorphingLabel/LTMorphingLabel+Sparkle.swift +++ b/LTMorphingLabel/LTMorphingLabel+Sparkle.swift @@ -90,7 +90,7 @@ extension LTMorphingLabel { } effectClosures["Sparkle\(phaseDisappear)"] = { - (char:Character, index: Int, progress: Float) in + char, index, progress in return LTCharacterLimbo( char: char, @@ -101,7 +101,7 @@ extension LTMorphingLabel { } effectClosures["Sparkle\(phaseAppear)"] = { - (char:Character, index: Int, progress: Float) in + char, index, progress in if char != " " { let rect = self.newRects[index] diff --git a/LTMorphingLabel/LTMorphingLabel.swift b/LTMorphingLabel/LTMorphingLabel.swift index 95f38b0..e15854e 100644 --- a/LTMorphingLabel/LTMorphingLabel.swift +++ b/LTMorphingLabel/LTMorphingLabel.swift @@ -62,7 +62,7 @@ typealias LTMorphingSkipFramesClosure = // MARK: - LTMorphingLabel -@IBDesignable public class LTMorphingLabel : UILabel { +@IBDesignable public class LTMorphingLabel: UILabel { @IBInspectable public var morphingProgress: Float = 0.0 @IBInspectable public var morphingDuration: Float = 0.6 @@ -95,7 +95,7 @@ typealias LTMorphingSkipFramesClosure = let presentingInIB = false #endif - override public var text:String! { + override public var text: String! { get { return super.text } @@ -136,7 +136,7 @@ typealias LTMorphingSkipFramesClosure = newRects = rectsOfEachCharacter(text ?? "", withFont: font) } - override public var bounds:CGRect { + override public var bounds: CGRect { get { return super.bounds } @@ -146,7 +146,7 @@ typealias LTMorphingSkipFramesClosure = } } - override public var frame:CGRect { + override public var frame: CGRect { get { return super.frame } @@ -211,7 +211,7 @@ extension LTMorphingLabel { // Could be enhanced by kerning text: // http://stackoverflow.com/questions/21443625/core-text-calculate-letter-frame-in-ios - func rectsOfEachCharacter(textToDraw:String, withFont font:UIFont) -> [CGRect] { + func rectsOfEachCharacter(textToDraw: String, withFont font: UIFont) -> [CGRect] { var charRects = [CGRect]() var leftOffset: CGFloat = 0.0 @@ -391,6 +391,7 @@ extension LTMorphingLabel { return limbo } + } @@ -418,7 +419,7 @@ extension LTMorphingLabel { } for charLimbo in limboOfCharacters() { - let charRect:CGRect = charLimbo.rect + let charRect = charLimbo.rect let willAvoidDefaultDrawing: Bool = { if let closure = drawingClosures[ @@ -440,4 +441,5 @@ extension LTMorphingLabel { } } } + } diff --git a/LTMorphingLabel/NSString+LTMorphingLabel.swift b/LTMorphingLabel/NSString+LTMorphingLabel.swift index 15d84b3..f524d54 100644 --- a/LTMorphingLabel/NSString+LTMorphingLabel.swift +++ b/LTMorphingLabel/NSString+LTMorphingLabel.swift @@ -28,7 +28,7 @@ import Foundation -public enum LTCharacterDiffType : Int, CustomDebugStringConvertible { +public enum LTCharacterDiffType: Int, CustomDebugStringConvertible { case Same = 0 case Add = 1 @@ -57,7 +57,7 @@ public enum LTCharacterDiffType : Int, CustomDebugStringConvertible { } -public struct LTCharacterDiffResult : CustomDebugStringConvertible { +public struct LTCharacterDiffResult: CustomDebugStringConvertible { public var diffType: LTCharacterDiffType = .Add public var moveOffset: Int = 0 diff --git a/LTMorphingLabelDemo.xcodeproj/project.pbxproj b/LTMorphingLabelDemo.xcodeproj/project.pbxproj index 39f8df3..f00dee5 100644 --- a/LTMorphingLabelDemo.xcodeproj/project.pbxproj +++ b/LTMorphingLabelDemo.xcodeproj/project.pbxproj @@ -268,6 +268,8 @@ D74AD96B195171E7009A2ACD /* Frameworks */, D74AD96C195171E7009A2ACD /* Resources */, D7D4B0371A5E87D50087F83D /* Embed Frameworks */, + D7E30A621C28449F00A708CF /* SwiftLint */, + D7E30A631C2844B000A708CF /* Tailor */, ); buildRules = ( ); @@ -305,7 +307,6 @@ D7D4B01B1A5E87D50087F83D /* Frameworks */, D7D4B01C1A5E87D50087F83D /* Headers */, D7D4B01D1A5E87D50087F83D /* Resources */, - D7CA19C31C17CE9A00F2EFDB /* SwiftLint */, ); buildRules = ( ); @@ -394,7 +395,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - D7CA19C31C17CE9A00F2EFDB /* SwiftLint */ = { + D7E30A621C28449F00A708CF /* SwiftLint */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -408,6 +409,20 @@ shellPath = /bin/sh; shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"SwiftLint does not exist, download from https://github.com/realm/SwiftLint\"\nfi"; }; + D7E30A631C2844B000A708CF /* Tailor */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = Tailor; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if hash tailor 2>/dev/null; then\ntailor ${SRCROOT}/LTMorphingLabel/ --except=trailing-whitespace,lower-camel-case\nelse\necho \"warning: Please install Tailor from https://tailor.sh\"\nfi"; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/LTMorphingLabelDemo.xcodeproj/project.xcworkspace/xcuserdata/lex.xcuserdatad/UserInterfaceState.xcuserstate b/LTMorphingLabelDemo.xcodeproj/project.xcworkspace/xcuserdata/lex.xcuserdatad/UserInterfaceState.xcuserstate index d1ae039..670fe66 100644 Binary files a/LTMorphingLabelDemo.xcodeproj/project.xcworkspace/xcuserdata/lex.xcuserdatad/UserInterfaceState.xcuserstate and b/LTMorphingLabelDemo.xcodeproj/project.xcworkspace/xcuserdata/lex.xcuserdatad/UserInterfaceState.xcuserstate differ