lexrus / LTMorphingLabel

[EXPERIMENTAL] Graceful morphing effects for UILabel written in Swift.
MIT License
8.05k stars 782 forks source link

Lags in the animation #124

Closed yurii-voievodin closed 4 years ago

yurii-voievodin commented 5 years ago

Lags in the animation on the latest version 0.6.0.

ltmorphinglabel 0 6 0 2019-01-30 15_28_42

And on 0.5.9 version of the library everything was ok.

ltmorphinglabel 0 5 9

My class AnimatedLabel added via Storyboard.

import LTMorphingLabel
import UIKit

class AnimatedLabel: LTMorphingLabel {

  required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)

    morphingEffect = .evaporate
    morphingDuration = 0.7
  }
}
lexrus commented 5 years ago

Thank you. I'll add a test case for this today.

yurii-voievodin commented 5 years ago

@lexrus And one important thing. On Simulator everything is OK. Lags appears only on device.

lexrus commented 5 years ago

@yura-voevodin Please check out the master branch. I just updated the demo with a progress control. And increased the total frame count. Could you also give the numbers of morphingDuration and morphingCharacterDelay so that I can reproduce the issue on my iPhone.

ownmas commented 5 years ago

Same issue. Video: https://drive.google.com/file/d/1pq7Tven49KUxgjgdLAGCGrxjsEJl_Nay/view?usp=drivesdk

You may download my app and see that issue: https://itunes.apple.com/us/app/repost-for-instagram-quick-ig/id1445207836

My code:

import UIKit
import StoreKit
import LTMorphingLabel

class InAppVC: UIViewController {

    @IBOutlet weak var morphLabel: LTMorphingLabel!

    // Morph label logic
    var timer: Timer?
    var morphTexts = [NSLocalizedString("morph_1", comment: ""), NSLocalizedString("morph_2", comment: ""), NSLocalizedString("morph_3", comment: ""), NSLocalizedString("morph_4", comment: ""), NSLocalizedString("morph_5", comment: ""), NSLocalizedString("morph_6", comment: ""), NSLocalizedString("morph_7", comment: "")]
    var morphTextIndex = 0

    // MARK: - INIT -
    deinit {
        killTimer()
    }

    // MARK: - VIEW LIFECYCLE -
    override func viewDidLoad() {
        super.viewDidLoad()
        if KeychainStore.isInAppBuyed {
            morphTexts.append("❤️")
        }
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        if self.timer == nil {
            setTimer()
        }
    }

    // MARK: - TIMER -
    func setTimer() {
        self.morphLabel.morphingEffect = .anvil
        self.timer = Timer.scheduledTimer(timeInterval: 1.5, target: self, selector: #selector(fire), userInfo: nil, repeats: true)
    }

    func killTimer() {
        timer?.invalidate()
        timer = nil
    }

    @objc private func fire() {
        if morphTextIndex >= morphTexts.count {
            morphTextIndex = 0
        }
        morphLabel.text = morphTexts[morphTextIndex]
        morphTextIndex += 1
    }

}
ownmas commented 5 years ago

I updated to latest commit and the problem is solved. Thank you! pod 'LTMorphingLabel', :git => 'https://github.com/lexrus/LTMorphingLabel.git', :commit => '757ed4c'

yurii-voievodin commented 5 years ago

@lexrus Works fine on the latest commit! I'm using morphingDuration = 0.7 and morphingCharacterDelay with default value.

marclefrancois commented 5 years ago

Would be nice if you did a Cocoapods release with the lag fix, Thanks