Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to show array of multiple text in one label by fade in and fade out

I want to show multiple quotation in one label and at a time only one quotation appear and quotation is coming from server side in array.
I am doing this -:

for i in self.splashModel?.quotations ?? [] {
        self.quoteLabel.alpha = 0
            self.quoteLabel.text = i
            self.quoteLabel.fadeIn(completion: {
                    (finished: Bool) -> Void in
                    self.quoteLabel.fadeOut()
                    })
       
    }

this code show only last quotation of array.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can try

self.splashModel?.quotations.enumerated().forEach { (index,item) in
    DispatchQueue.main.asyncAfter(deadline: .now() + Double( index * 2) ) {
        self.quoteLabel.alpha = 0
        self.quoteLabel.text = item
        self.quoteLabel.fadeIn(completion: {(finished: Bool) -> Void in
           self.quoteLabel.fadeOut()
       })
    } 
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading