Skip to content

Commit 0ee594a

Browse files
committed
to Swift 5
1 parent c515514 commit 0ee594a

File tree

6 files changed

+28
-21
lines changed

6 files changed

+28
-21
lines changed

Example/Pods/Pods.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/SpringText.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@
484484
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
485485
PRODUCT_NAME = "$(TARGET_NAME)";
486486
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
487-
SWIFT_VERSION = 4.0;
487+
SWIFT_VERSION = 5.0;
488488
};
489489
name = Debug;
490490
};
@@ -499,7 +499,7 @@
499499
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
500500
PRODUCT_NAME = "$(TARGET_NAME)";
501501
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
502-
SWIFT_VERSION = 4.0;
502+
SWIFT_VERSION = 5.0;
503503
};
504504
name = Release;
505505
};

Example/SpringText/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414
var window: UIWindow?
1515

1616

17-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1818
// Override point for customization after application launch.
1919
return true
2020
}

Example/SpringText/Base.lproj/Main.storyboard

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<dependencies>
55
<deployment identifier="iOS"/>
66
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
7+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
78
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
89
</dependencies>
910
<scenes>
@@ -19,15 +20,20 @@
1920
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2021
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2122
<subviews>
22-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sIj-hc-Uk3" customClass="TPCountLabel" customModule="SpringText">
23-
<rect key="frame" x="16" y="20" width="42" height="21"/>
24-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
23+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sIj-hc-Uk3" customClass="TPCountLabel" customModule="SpringText">
24+
<rect key="frame" x="36" y="20" width="303" height="21"/>
25+
<color key="backgroundColor" systemColor="systemPinkColor"/>
2526
<fontDescription key="fontDescription" type="system" pointSize="17"/>
2627
<nil key="textColor"/>
2728
<nil key="highlightedColor"/>
2829
</label>
2930
</subviews>
3031
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
32+
<constraints>
33+
<constraint firstItem="sIj-hc-Uk3" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" constant="20" id="6B7-u4-i0a"/>
34+
<constraint firstItem="sIj-hc-Uk3" firstAttribute="top" secondItem="jyV-Pf-zRb" secondAttribute="bottom" constant="20" id="E34-np-fky"/>
35+
<constraint firstAttribute="trailingMargin" secondItem="sIj-hc-Uk3" secondAttribute="trailing" constant="20" id="tdT-yc-Eq0"/>
36+
</constraints>
3137
</view>
3238
<connections>
3339
<outlet property="lblTitle" destination="sIj-hc-Uk3" id="LcL-HP-JCM"/>
@@ -38,4 +44,9 @@
3844
<point key="canvasLocation" x="138" y="133"/>
3945
</scene>
4046
</scenes>
47+
<resources>
48+
<systemColor name="systemPinkColor">
49+
<color red="1" green="0.17647058823529413" blue="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
50+
</systemColor>
51+
</resources>
4152
</document>

Example/SpringText/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ViewController: UIViewController {
1313
@IBOutlet weak var lblTitle: TPCountLabel!
1414

1515
override func viewDidLoad() {
16-
lblTitle.configure(with:10)
16+
lblTitle.text(num: 28787123)
1717
}
1818

1919
override func didReceiveMemoryWarning() {

SpringText/Classes/SPLabel.swift

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//
77

88
import UIKit
9-
import QuartzCore
109

1110
extension UILabel {
1211
func textWidth() -> CGFloat {
@@ -30,15 +29,6 @@ extension UILabel {
3029
}
3130
}
3231

33-
34-
extension TPCountLabel {
35-
func text(num: Int, hasWon: Bool = true) {
36-
self.hasWon = hasWon
37-
self.configure(with: num)
38-
self.animate()
39-
}
40-
}
41-
4232
extension Int {
4333
var currency: String {
4434
let numberFormatter = NumberFormatter()
@@ -74,6 +64,12 @@ open class TPCountLabel: UILabel {
7464
private let durationOffset = 0.2
7565
private let textsNotAnimated = [","]
7666

67+
public func text(num: Int, hasWon: Bool = true) {
68+
self.hasWon = hasWon
69+
self.configure(with: num)
70+
self.animate()
71+
}
72+
7773
public func configure(with number: Int) {
7874
let text = number.currency
7975
fullText = text
@@ -200,7 +196,7 @@ open class TPCountLabel: UILabel {
200196

201197
let animation = CABasicAnimation(keyPath: "sublayerTransform.translation.y")
202198
animation.duration = duration + offset
203-
// animation.timingFunction = CAMediaTimingFunction(name: .easeOut)
199+
animation.timingFunction = CAMediaTimingFunction(name: .easeOut)
204200

205201
if ascending {
206202
animation.fromValue = maxY
@@ -210,7 +206,7 @@ open class TPCountLabel: UILabel {
210206
animation.toValue = maxY
211207
}
212208

213-
// scrollLayer.scrollMode = .vertically
209+
scrollLayer.scrollMode = .vertically
214210
// custom key 설정
215211
scrollLayer.add(animation, forKey: nil)
216212
scrollLayer.scroll(to: CGPoint(x: 0, y: maxY))

0 commit comments

Comments
 (0)