@@ -60,7 +60,7 @@ public class BadgeHub: NSObject {
60
60
private var isIndeterminateMode = false
61
61
62
62
// MARK: - SETUP
63
- init ( view: UIView ) {
63
+ public init ( view: UIView ) {
64
64
super. init ( )
65
65
66
66
maxCount = 100000
@@ -76,7 +76,7 @@ public class BadgeHub: NSObject {
76
76
// }
77
77
78
78
// Adjustment methods
79
- func setView( _ view: UIView ? , andCount startCount: Int ) {
79
+ public func setView( _ view: UIView ? , andCount startCount: Int ) {
80
80
curOrderMagnitude = 0
81
81
82
82
let frame : CGRect ? = view? . frame
@@ -106,7 +106,7 @@ public class BadgeHub: NSObject {
106
106
}
107
107
108
108
// Set the frame of the notification circle relative to the button
109
- func setCircleAtFrame( _ frame: CGRect ) {
109
+ public func setCircleAtFrame( _ frame: CGRect ) {
110
110
redCircle. frame = frame
111
111
initialCenter = CGPoint ( x: frame. origin. x + frame. size. width / 2 , y: frame. origin. y + frame. size. height / 2 )
112
112
baseFrame = frame
@@ -118,29 +118,28 @@ public class BadgeHub: NSObject {
118
118
}
119
119
120
120
// Change the color of the notification circle
121
- func setCircleColor( _ circleColor: UIColor ? , label labelColor: UIColor ? ) {
121
+ public func setCircleColor( _ circleColor: UIColor ? , label labelColor: UIColor ? ) {
122
122
redCircle. isUserChangingBackgroundColor = true
123
123
redCircle. backgroundColor = circleColor
124
124
if let labelColor = labelColor {
125
125
countLabel? . textColor = labelColor
126
126
}
127
127
}
128
128
129
- func setCircleBorderColor( _ color: UIColor ? , borderWidth width: CGFloat ) {
129
+ public func setCircleBorderColor( _ color: UIColor ? , borderWidth width: CGFloat ) {
130
130
redCircle. layer. borderColor = color? . cgColor
131
131
redCircle. layer. borderWidth = width
132
132
}
133
133
134
-
135
- func moveCircleBy( x: CGFloat , y: CGFloat ) {
134
+ public func moveCircleBy( x: CGFloat , y: CGFloat ) {
136
135
var frame : CGRect = redCircle. frame
137
136
frame. origin. x += x
138
137
frame. origin. y += y
139
138
self . setCircleAtFrame ( frame)
140
139
}
141
140
142
141
// Changes the size of the circle. setting a scale of 1 has no effect
143
- func scaleCircleSize( by scale: CGFloat ) {
142
+ public func scaleCircleSize( by scale: CGFloat ) {
144
143
let fr : CGRect = initialFrame
145
144
let width : CGFloat = fr. size. width * scale
146
145
let height : CGFloat = fr. size. height * scale
@@ -152,41 +151,41 @@ public class BadgeHub: NSObject {
152
151
}
153
152
154
153
// Increases count by 1
155
- func increment( ) {
154
+ public func increment( ) {
156
155
increment ( by: 1 )
157
156
}
158
157
159
158
// Increases count by amount
160
- func increment( by amount: Int ) {
159
+ public func increment( by amount: Int ) {
161
160
count += amount
162
161
}
163
162
164
163
// Decreases count
165
- func decrement( ) {
164
+ public func decrement( ) {
166
165
decrement ( by: 1 )
167
166
}
168
167
169
168
// Decreases count by amount
170
- func decrement( by amount: Int ) {
169
+ public func decrement( by amount: Int ) {
171
170
if amount >= count {
172
171
count = 0
173
172
return
174
173
}
175
174
count -= amount
176
175
}
177
176
178
- func hideCount( ) {
177
+ public func hideCount( ) {
179
178
countLabel? . isHidden = true
180
179
isIndeterminateMode = true
181
180
}
182
181
183
- func showCount( ) {
182
+ public func showCount( ) {
184
183
isIndeterminateMode = false
185
184
checkZero ( )
186
185
}
187
186
188
187
// Animations
189
- func pop( ) {
188
+ public func pop( ) {
190
189
let height = baseFrame. size. height
191
190
let width = baseFrame. size. width
192
191
let popStartHeight : Float = Float ( height * popStartRatio)
@@ -273,7 +272,7 @@ public class BadgeHub: NSObject {
273
272
}
274
273
}
275
274
276
- func blink( ) {
275
+ public func blink( ) {
277
276
self . setAlpha ( alpha: Float ( blinkAlpha) )
278
277
279
278
UIView . animate ( withDuration: TimeInterval ( blinkDuration) , animations: {
@@ -290,7 +289,7 @@ public class BadgeHub: NSObject {
290
289
}
291
290
292
291
// Animation that jumps similar to OSX dock icons
293
- func bump( ) {
292
+ public func bump( ) {
294
293
if !initialCenter. equalTo ( redCircle. center) {
295
294
// canel previous animation
296
295
}
@@ -313,9 +312,8 @@ public class BadgeHub: NSObject {
313
312
}
314
313
}
315
314
316
-
317
315
// Set the count yourself
318
- func setCount( _ newCount: Int ) {
316
+ public func setCount( _ newCount: Int ) {
319
317
count = newCount
320
318
321
319
var labelText = " \( NSNumber ( value: count) ) "
@@ -330,28 +328,28 @@ public class BadgeHub: NSObject {
330
328
}
331
329
332
330
// Set the font of the label
333
- func setCountLabel( _ font: UIFont ? ) {
331
+ public func setCountLabel( _ font: UIFont ? ) {
334
332
countLabel? . font = font
335
333
}
336
334
337
- func countLabelFont( ) -> UIFont ? {
335
+ public func countLabelFont( ) -> UIFont ? {
338
336
return countLabel? . font
339
337
}
340
338
341
339
342
- func bumpCenterY( yVal: Float ) {
340
+ public func bumpCenterY( yVal: Float ) {
343
341
var center : CGPoint = redCircle. center
344
342
center. y = initialCenter. y - CGFloat( yVal)
345
343
redCircle. center = center
346
344
countLabel? . center = center
347
345
}
348
346
349
- func setAlpha( alpha: Float ) {
347
+ public func setAlpha( alpha: Float ) {
350
348
redCircle. alpha = CGFloat ( alpha)
351
349
countLabel? . alpha = CGFloat ( alpha)
352
350
}
353
351
354
- func checkZero( ) {
352
+ public func checkZero( ) {
355
353
if count <= 0 {
356
354
redCircle. isHidden = true
357
355
countLabel? . isHidden = true
0 commit comments