Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animation stops when returns to view using Navigation Bar #21

Open
junaidxabd opened this issue Jun 10, 2017 · 7 comments
Open

Animation stops when returns to view using Navigation Bar #21

junaidxabd opened this issue Jun 10, 2017 · 7 comments

Comments

@junaidxabd
Copy link

If you press back to go back to the view with the animation (in the navigation controller stack) the animation doesn’t work.

@Xopoko
Copy link

Xopoko commented Sep 20, 2017

Same problem, swipe to back, too

@chrismgala
Copy link

Having the same problem as well. Tried moving the code from viewDidLoad to viewWillAppear as that is called each time the view is reloaded but didn't help.

@dopefaceee
Copy link

anyone resolve the issue ?

@sblatz
Copy link

sblatz commented Feb 6, 2018

Bump. Also having this issue whenever the view disappears and reappears (like upon minimizing the app and opening again).

@DaveCC94
Copy link

DaveCC94 commented Feb 11, 2018

I have some kind of workaround, but you may not like it.

In my case I created a subclass from UIButton, then I added the gradient there and unluckily for me I crossed with this issue, so what I did next is to override willMove like this

override func willMove(toWindow newWindow: UIWindow?) {
    if newWindow == nil {
        // We remove the view
        self.subviews[0].removeFromSuperview()
    } else {
        // Add we re-added the Pastel View here
    }
}

I personally don't like to mess with this methods because this can lead to some errors, but in this way we can remove the unmoving view and add it again.

Also, I didn't notice any significant memory leak, it spikes to 0.1MB when displayed and then it gets to 0 as soon as the PastelView is removed.

@Umity
Copy link

Umity commented Apr 23, 2018

tried viewdidAppear but didnt help..

@iambenmitchell
Copy link

override func viewDidLoad() {
    super.viewDidLoad()
    gradient()
    NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground), name: UIApplication.willEnterForegroundNotification
        , object: nil)

}

@objc func willEnterForeground() {
    print("test")
    gradient()
}

func gradient(){
    let pastelView = PastelView(frame: view.bounds)
    
    // Custom Direction
    pastelView.startPastelPoint = .bottomLeft
    pastelView.endPastelPoint = .topRight
    
    // Custom Duration
    pastelView.animationDuration = 1.5
    
    // Custom Color
    pastelView.setColors([UIColor(red: 156/255, green: 39/255, blue: 176/255, alpha: 1.0),
                          UIColor(red: 255/255, green: 64/255, blue: 129/255, alpha: 1.0),
                          UIColor(red: 123/255, green: 31/255, blue: 162/255, alpha: 1.0),
                          UIColor(red: 32/255, green: 76/255, blue: 255/255, alpha: 1.0),
                          UIColor(red: 32/255, green: 158/255, blue: 255/255, alpha: 1.0),
                          UIColor(red: 90/255, green: 120/255, blue: 127/255, alpha: 1.0),
                          UIColor(red: 58/255, green: 255/255, blue: 217/255, alpha: 1.0)])
    
    
    pastelView.startAnimation()
    view.insertSubview(pastelView, at: 0)
    print("Test1")
}

"Test" and "Test1" is printed to the console, yet the animation refuses to resume

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants