1

I have a UITextView that animates from off the screen (below). It works great, unless I press the home button and return to the app. Then, the text scrolls over the Tab Bar Controller, and doesn't stay within the view area. I'm running Xcode 13. The issue happens on both the simulator and my iPhone12. As always, I greatly appreciate your help. Here's my code:

import UIKit

class InfoViewController: UIViewController {

@IBOutlet weak var helpText: UITextView!




override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    animate()
}

// ***************************************************************
// MARK: Animate text view from below screen
// ***************************************************************
func animate() {
    UIView.animate(withDuration: 4.0, delay: -0.0, options: []) {
        self.helpText.frame.origin.y -= 700
    }
}

// ***************************************************************
// MARK: Reset view so it properly animates during
// subsequent views/loads.
// ***************************************************************
override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    self.helpText.frame.origin.y += 700
}

}

Here are samples of good and bad operations:

Working example.

Failing example.

Iggy
  • 33
  • 6

0 Answers0