Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 2698ab0

Browse files
committed
Update 1.2.1
- change enum name from buttonStyle to DayButtonStyle - delete unused code in NormalCalendar.swift - update README
1 parent 136fedf commit 2698ab0

File tree

7 files changed

+30
-51
lines changed

7 files changed

+30
-51
lines changed

README.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,22 @@ calendar.show()
3737
You can set calendar style properties (color, font, ...)
3838

3939
```swift
40-
calendar.dimmedBackgroundColor: UIColor = UIColor.black
41-
calendar.dimmedBackgroundAlpha: CGFloat = 0.5
42-
calendar.headerViewBackgroundColor: UIColor = Useful.getUIColor(245, 245, 245)
43-
calendar.bodyViewBackgroundColor: UIColor = Useful.getUIColor(255, 255, 255)
44-
calendar.sundayColor: UIColor = Useful.getUIColor(235, 61, 79)
45-
calendar.disabledSundayColor: UIColor = Useful.getUIColor(251, 197, 202)
46-
calendar.saturdayColor: UIColor = Useful.getUIColor(53, 113, 214)
47-
calendar.disabledSaturdayColor: UIColor = Useful.getUIColor(194, 212, 243)
48-
calendar.defaultDayColor: UIColor = Useful.getUIColor(51, 51, 51)
49-
calendar.disabledDefaultDayColor: UIColor = Useful.getUIColor(193, 193, 193)
50-
calendar.lineSeparatorColor: UIColor = Useful.getUIColor(233, 233, 233)
51-
calendar.headerLabelFont: UIFont = UIFont.systemFont(ofSize: 24)
52-
calendar.weekLabelFont: UIFont = UIFont.systemFont(ofSize: 16)
53-
calendar.dayLabelFont: UIFont = UIFont.systemFont(ofSize: 19)
40+
calendar.dayButtonStyle = DayButtonStyle (.roundishSquare, .square, .circle)
41+
calendar.dimmedBackgroundColor = UIColor
42+
calendar.dimmedBackgroundAlpha = CGFloat
43+
calendar.headerViewBackgroundColor = UIColor
44+
calendar.bodyViewBackgroundColor = UIColor
45+
calendar.sundayColor = UIColor
46+
calendar.disabledSundayColor = UIColor
47+
calendar.saturdayColor = UIColor
48+
calendar.disabledSaturdayColor = UIColor
49+
calendar.defaultDayColor = UIColor
50+
calendar.disabledDefaultDayColor = UIColor
51+
calendar.lineSeparatorColor = UIColor
52+
calendar.selectedDayColor = UIColor
53+
calendar.headerLabelFont = UIFont
54+
calendar.weekLabelFont = UIFont
55+
calendar.dayLabelFont = UIFont
5456
```
5557

5658
## Calendar Type

YYCalendar.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 = 'YYCalendar'
11-
s.version = '1.2.0'
11+
s.version = '1.2.1'
1212
s.swift_version = '5.0'
1313
s.summary = 'Very Simple and Useful Calendar'
1414

YYCalendar/Classes/Components/DayButton.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ class DayButton: UIButton {
1313
var selectedDayColor: UIColor = Useful.getUIColor(55, 137, 220)
1414
var beforeTextColor: UIColor = Useful.getUIColor(51, 51, 51)
1515
var todayIconImageView: UIImageView!
16-
var buttonStyle: ButtonStyle = .roundishSquare
16+
var dayButtonStyle: DayButtonStyle = .roundishSquare
1717

18-
// To set the buttonStyle
18+
// To set the dayButtonStyle
1919
override var bounds: CGRect {
2020
didSet {
21-
switch buttonStyle {
21+
switch dayButtonStyle {
2222
case .roundishSquare:
2323
self.layer.cornerRadius = 10
2424
case .square:
@@ -29,13 +29,13 @@ class DayButton: UIButton {
2929
}
3030
}
3131

32-
init(style: ButtonStyle) {
32+
init(style: DayButtonStyle) {
3333
super.init(frame: CGRect.zero)
3434

3535
setupTodayIcon()
3636
setupAutoLayout()
3737

38-
self.buttonStyle = style
38+
self.dayButtonStyle = style
3939
self.todayIconImageView.isHidden = true
4040
}
4141

YYCalendar/Classes/Components/LimitedCalendar.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import UIKit
3030
var dayStackView: UIStackView!
3131

3232
// MARK: - Calendar Style
33-
var buttonStyle: ButtonStyle = .roundishSquare
33+
var dayButtonStyle: DayButtonStyle = .roundishSquare
3434
var hideDuration: Double = 0.3
3535
var dimmedBackgroundColor: UIColor = UIColor.black
3636
var dimmedBackgroundAlpha: CGFloat = 0.5
@@ -310,7 +310,7 @@ import UIKit
310310
tempStackView.distribution = .fillEqually
311311

312312
for column in 1...7 {
313-
let tempButton = DayButton(style: buttonStyle)
313+
let tempButton = DayButton(style: dayButtonStyle)
314314
tempButton.translatesAutoresizingMaskIntoConstraints = false
315315
tempButton.heightAnchor.constraint(equalTo: tempButton.widthAnchor).isActive = true
316316
tempButton.titleLabel?.font = self.dayLabelFont

YYCalendar/Classes/Components/NormalCalendar.swift

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import UIKit
3030
var dayStackView: UIStackView!
3131

3232
// MARK: - Calendar Style
33-
var buttonStyle: ButtonStyle = .roundishSquare
33+
var dayButtonStyle: DayButtonStyle = .roundishSquare
3434
var hideDuration: Double = 0.3
3535
var dimmedBackgroundColor: UIColor = UIColor.black
3636
var dimmedBackgroundAlpha: CGFloat = 0.5
@@ -300,7 +300,7 @@ import UIKit
300300
tempStackView.distribution = .fillEqually
301301

302302
for column in 1...7 {
303-
let tempButton = DayButton(style: buttonStyle)
303+
let tempButton = DayButton(style: dayButtonStyle)
304304
tempButton.translatesAutoresizingMaskIntoConstraints = false
305305
tempButton.heightAnchor.constraint(equalTo: tempButton.widthAnchor).isActive = true
306306
tempButton.titleLabel?.font = self.dayLabelFont
@@ -482,29 +482,6 @@ import UIKit
482482
}
483483
}
484484

485-
// set dayButton's color
486-
func setDayButtonStyle(button: DayButton, weekDay: Int, enabled: Bool) {
487-
button.isEnabled = enabled
488-
489-
if enabled {
490-
if weekDay == 1 { // Sunday
491-
button.setTitleColor(self.sundayColor, for: .normal)
492-
} else if weekDay == 7 { // Saturday
493-
button.setTitleColor(self.saturdayColor, for: .normal)
494-
} else { // Weekday
495-
button.setTitleColor(self.defaultDayColor, for: .normal)
496-
}
497-
} else {
498-
if weekDay == 1 { // Sunday
499-
button.setTitleColor(self.disabledSundayColor, for: .normal)
500-
} else if weekDay == 7 { // Saturday
501-
button.setTitleColor(self.disabledSaturdayColor, for: .normal)
502-
} else { // Weekday
503-
button.setTitleColor(self.disabledDefaultDayColor, for: .normal)
504-
}
505-
}
506-
}
507-
508485
// MARK: - Click Event
509486
@objc func changeMonthOrYear(_ sender: UIButton) {
510487
switch sender.restorationIdentifier {

YYCalendar/Classes/Constants.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public enum LangType {
3131
case CHN
3232
}
3333

34-
public enum ButtonStyle {
34+
public enum DayButtonStyle {
3535
case roundishSquare
3636
case square
3737
case circle

YYCalendar/Classes/YYCalendar.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ import Foundation
3636
}
3737

3838
// MARK: - Calendar Style Properties
39-
public var buttonStyle: ButtonStyle = .roundishSquare {
39+
public var dayButtonStyle: DayButtonStyle = .roundishSquare {
4040
didSet {
4141
weak var weakSelf = self
4242
if let weakSelf = weakSelf {
4343
switch componentType {
4444
case .normal:
45-
weakSelf.normalCalendar?.buttonStyle = buttonStyle
45+
weakSelf.normalCalendar?.dayButtonStyle = dayButtonStyle
4646
case .limited:
47-
weakSelf.limitedCalendar?.buttonStyle = buttonStyle
47+
weakSelf.limitedCalendar?.dayButtonStyle = dayButtonStyle
4848
}
4949
}
5050
}

0 commit comments

Comments
 (0)