Skip to content

Commit 168fc37

Browse files
committed
[ SJ.H ] : update symbol, curruncy options
1 parent 171b8bf commit 168fc37

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

Example/SpringText/ViewController.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ class ViewController: UIViewController {
1616
@IBOutlet weak var lbl_num4: SPLabel!
1717

1818
override func viewDidLoad() {
19+
lbl_num1.isCurrency = false
20+
lbl_num1.showSymbol = false
1921
lbl_num1.text(num: 1000000000)
20-
lbl_num2.text(num: 1000000000, showCurrency: true)
22+
23+
lbl_num2.text(num: 1000000000)
2124
lbl_num3.text(num: 1234567890)
25+
2226
lbl_num4.setCurrency(symbol: "")
23-
lbl_num4.text(num: 1234567890, showCurrency:true)
27+
lbl_num4.text(num: 1234567890)
2428

2529
let newLabel = SPLabel(frame: CGRect(x: 50, y: 200, width: 100, height: 100))
2630
newLabel.text(num: 1203901293)

SpringText.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'SpringText'
11-
s.version = '1.1.3'
11+
s.version = '1.1.4'
1212
s.summary = 'Summary SpringText.'
1313

1414
# This description is used to generate tags and improve search results.

SpringText/Classes/SPLabel.swift

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@
88
import UIKit
99

1010
open class SPLabel: UILabel {
11-
var fullText = ""
11+
private var fullText = ""
12+
13+
open var isCurrency = true
14+
1215
private var currencySymbol: String = "$"
13-
private var showCurrency: Bool = true
16+
open var showSymbol = true
1417
private var scrollLayers: [CAScrollLayer] = []
1518
private var scrollLabels: [UILabel] = []
1619
private let duration = 0.7
1720
private let durationOffset = 0.2
1821
private let textsNotAnimated = [","]
1922

20-
public func text(num: Int, showCurrency: Bool = false) {
21-
self.showCurrency = showCurrency
23+
public func text(num: Int) {
2224
self.configure(with: num)
2325
self.text = " "
2426
self.animate()
@@ -29,8 +31,12 @@ open class SPLabel: UILabel {
2931
}
3032

3133
private func configure(with number: Int) {
32-
let text = number.currency
33-
fullText = text
34+
if isCurrency {
35+
fullText = number.currency
36+
} else {
37+
fullText = String(number)
38+
}
39+
3440
clean()
3541
setupSubviews()
3642
}
@@ -52,7 +58,7 @@ open class SPLabel: UILabel {
5258
var x: CGFloat = 0
5359
let y: CGFloat = 0
5460
if self.textAlignment == .center {
55-
if showCurrency {
61+
if showSymbol {
5662
self.text = "\(currencySymbol) \(fullText)"
5763
} else {
5864
self.text = fullText
@@ -61,7 +67,7 @@ open class SPLabel: UILabel {
6167
self.text = "" // 초기화
6268
x = -(w / 2)
6369
} else if self.textAlignment == .right {
64-
if showCurrency {
70+
if showSymbol {
6571
self.text = "\(currencySymbol) \(fullText)"
6672
} else {
6773
self.text = fullText
@@ -71,7 +77,7 @@ open class SPLabel: UILabel {
7177
x = -w
7278
}
7379

74-
if showCurrency {
80+
if showSymbol {
7581
let wLabel = UILabel()
7682
wLabel.frame.origin = CGPoint(x: x, y: y)
7783
wLabel.textColor = textColor

0 commit comments

Comments
 (0)