Pastel
Pastel copied to clipboard
Animation does not cycle through all colors
(Sorry if I'm doing this incorrectly, somewhat new to issues)
In my app I've set a PastelView as a background view of a UITableView in a UITableViewController. The PastelView will only animate through the first 3 colors provided. The default configuration (when no custom colors, start/end points, or duration are set) has the same issue.
Thank you for your new issue :D However, I did not encounter any problems when I created a simple table view controller example using 7 colors( rainbow colors )
Can you show me a problem with some repository using PastelView ?
I think that will help solve the problem. :D
Here is the code that I am using.
import UIKit
import Pastel
class AddNewMemberTableViewController: UITableViewController {
@IBOutlet weak var tableBackgroundView: PastelView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.backgroundView = tableBackgroundView
setupPastelView()
}
// MARK - Setup
private func setupPastelView() {
tableBackgroundView.startPoint = .bottomLeft
tableBackgroundView.endPoint = .topRight
tableBackgroundView.animationDuration = 15.0
tableBackgroundView.setColors(colors: [#colorLiteral(red: 0.9411764741, green: 0.4980392158, blue: 0.3529411852, alpha: 1),
#colorLiteral(red: 0.9686274529, green: 0.78039217, blue: 0.3450980484, alpha: 1),
#colorLiteral(red: 0.5843137503, green: 0.8235294223, blue: 0.4196078479, alpha: 1),
#colorLiteral(red: 0.2588235438, green: 0.7568627596, blue: 0.9686274529, alpha: 1),
#colorLiteral(red: 0.3647058904, green: 0.06666667014, blue: 0.9686274529, alpha: 1),
#colorLiteral(red: 0.8549019694, green: 0.250980407, blue: 0.4784313738, alpha: 1)])
tableBackgroundView.startAnimation()
}
}
it works fine to me but its too slow to show all colors because it takes 15 seconds per pair color set please check this branch fix/issue6-cycle-not-working it works too
Interesting. I will try it this evening when I am off work. Thanks for looking into this.
I hope this example solves the problem. :)
I found the problem in my app was starting the animation in viewDidLoad
. Moving pastelView.startAnimation()
to viewDidAppear
fixed the issue. I also found that viewWillAppear
also works. Assuming you're content with this functionality, I would say this could be closed!
More, You will know that it will be stopped when view is not in front. So, viewDidAppear will always call startAnimation
Cheers!
Yes, had the same issue, in one ViewController it only worked in viewDidAppear. The only difference I could tell was that the first VC (where it worked in viewDidLoad) was created from Storyboard, the other one not.