Home IOS Development ios – UIHostingController mistaken peak animation

ios – UIHostingController mistaken peak animation

0
ios – UIHostingController mistaken peak animation

[ad_1]

In iOS 17, at any time when I modify the peak of a UIHostingController in a animation block, the basis SwiftUI.View ignores it:

class TestAnimationController: UIViewController {

    var heightConstraint: NSLayoutConstraint!

    // a primary set off
    override func touchesEnded(_ touches: Set<UITouch>, with occasion: UIEvent?) {
        tremendous.touchesEnded(touches, with: occasion)
        heightConstraint.fixed = heightConstraint.fixed == 300 ? 100 : 300
        UIView.animate(withDuration: 1.0) {
            self.view.layoutIfNeeded()
        }
    }

    override func viewDidLoad() {
        tremendous.viewDidLoad()
        let content material = UIHostingController(rootView: Colour.crimson)
        addChild(content material)
        view.addSubview(content material.view)
        content material.view.translatesAutoresizingMaskIntoConstraints = false
        heightConstraint = contentView.heightAnchor.constraint(equalToConstant: 100)
        heightConstraint.isActive = true
        contentView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
        contentView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
        contentView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
        content material.didMove(toParent: self)
    }
}

The result’s horrible:

It was not the case in iOS 14.5:

iOS 14

Does somebody have a workaround?

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here