Skip to content
This repository was archived by the owner on May 18, 2021. It is now read-only.

Commit dec78d5

Browse files
committed
change currentColor
1 parent 01e4669 commit dec78d5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Project 19 - CustomPullToRefresh/CustomPullToRefresh/ViewController.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ class ViewController: UIViewController,UITableViewDelegate {
2323
let transformColors: [UIColor] = [.magenta, .brown, .yellow, .red, .green, .blue, .orange]
2424
var currentColorIndex = 0
2525

26-
lazy var currentColor: () -> UIColor = {
26+
var currentColor: UIColor {
2727
//获取当前颜色
28-
let returnColor = self.transformColors[self.currentColorIndex]
28+
let color = transformColors[currentColorIndex]
2929
//设置下一个颜色的游标
30-
self.currentColorIndex = (self.currentColorIndex + 1) % self.transformColors.count
31-
return returnColor
30+
currentColorIndex = (currentColorIndex + 1) % transformColors.count
31+
return color
3232
}
3333

3434
override func viewDidLoad() {
@@ -90,7 +90,7 @@ class ViewController: UIViewController,UITableViewDelegate {
9090

9191
UIView.animate(withDuration: 0.1, delay: 0.0, options: UIViewAnimationOptions.curveLinear, animations: { () -> Void in
9292
self.labelsArray[self.currentLabelIndex].transform = CGAffineTransform(rotationAngle: CGFloat(M_PI_4))
93-
self.labelsArray[self.currentLabelIndex].textColor = self.currentColor()
93+
self.labelsArray[self.currentLabelIndex].textColor = self.currentColor
9494
}, completion: { (finished) -> Void in
9595
UIView.animate(withDuration: 0.05, delay: 0.0, options: .curveLinear, animations: { () -> Void in
9696
self.labelsArray[self.currentLabelIndex].transform = .identity

0 commit comments

Comments
 (0)