8
8
import UIKit
9
9
10
10
open class SPLabel : UILabel {
11
- var fullText = " "
11
+ private var fullText = " "
12
+
13
+ open var isCurrency = true
14
+
12
15
private var currencySymbol : String = " $ "
13
- private var showCurrency : Bool = true
16
+ open var showSymbol = true
14
17
private var scrollLayers : [ CAScrollLayer ] = [ ]
15
18
private var scrollLabels : [ UILabel ] = [ ]
16
19
private let duration = 0.7
17
20
private let durationOffset = 0.2
18
21
private let textsNotAnimated = [ " , " ]
19
22
20
- public func text( num: Int , showCurrency: Bool = false ) {
21
- self . showCurrency = showCurrency
23
+ public func text( num: Int ) {
22
24
self . configure ( with: num)
23
25
self . text = " "
24
26
self . animate ( )
@@ -29,8 +31,12 @@ open class SPLabel: UILabel {
29
31
}
30
32
31
33
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
+
34
40
clean ( )
35
41
setupSubviews ( )
36
42
}
@@ -52,7 +58,7 @@ open class SPLabel: UILabel {
52
58
var x : CGFloat = 0
53
59
let y : CGFloat = 0
54
60
if self . textAlignment == . center {
55
- if showCurrency {
61
+ if showSymbol {
56
62
self . text = " \( currencySymbol) \( fullText) "
57
63
} else {
58
64
self . text = fullText
@@ -61,7 +67,7 @@ open class SPLabel: UILabel {
61
67
self . text = " " // 초기화
62
68
x = - ( w / 2 )
63
69
} else if self . textAlignment == . right {
64
- if showCurrency {
70
+ if showSymbol {
65
71
self . text = " \( currencySymbol) \( fullText) "
66
72
} else {
67
73
self . text = fullText
@@ -71,7 +77,7 @@ open class SPLabel: UILabel {
71
77
x = - w
72
78
}
73
79
74
- if showCurrency {
80
+ if showSymbol {
75
81
let wLabel = UILabel ( )
76
82
wLabel. frame. origin = CGPoint ( x: x, y: y)
77
83
wLabel. textColor = textColor
0 commit comments