Pastel icon indicating copy to clipboard operation
Pastel copied to clipboard

Animation does not cycle through all colors

Open ekoranek12 opened this issue 7 years ago • 9 comments

(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.

ekoranek12 avatar May 15 '17 03:05 ekoranek12

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

cruisediary avatar May 16 '17 15:05 cruisediary

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()
    }

}

ekoranek12 avatar May 16 '17 15:05 ekoranek12

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

cruisediary avatar May 16 '17 15:05 cruisediary

Interesting. I will try it this evening when I am off work. Thanks for looking into this.

ekoranek12 avatar May 16 '17 15:05 ekoranek12

I hope this example solves the problem. :)

cruisediary avatar May 16 '17 15:05 cruisediary

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!

ekoranek12 avatar May 16 '17 22:05 ekoranek12

More, You will know that it will be stopped when view is not in front. So, viewDidAppear will always call startAnimation

Cheers!

younatics avatar Jun 04 '17 13:06 younatics

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.

ThreadPitt avatar Jul 02 '17 12:07 ThreadPitt