Skip to content

Weird animation when using AutoLayout #29

Open

Description

@ricardopereira

If I use SpringIndicator with AutoLayout, the animation doesn't work correctly.

AutoLayout:

screen recording 2018-09-17 at 07 00 pm

No AutoLayout:

screen recording 2018-09-17 at 07 01 pm

Code:

class ViewController: UIViewController {

    lazy var springIndicatorView: SpringIndicator = {
        let indicator = SpringIndicator(frame: CGRect(x: 100, y: 100, width: 60, height: 60))
        indicator.translatesAutoresizingMaskIntoConstraints = false
        return indicator
    }()

    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(springIndicatorView)
        springIndicatorView.rotationDuration = 2
        springIndicatorView.lineColor = .red
        springIndicatorView.lineWidth = 2
        NSLayoutConstraint.activate([
            springIndicatorView.topAnchor.constraint(equalTo: view.topAnchor, constant: 40),
            springIndicatorView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
            springIndicatorView.heightAnchor.constraint(equalToConstant: 40),
            springIndicatorView.widthAnchor.constraint(equalToConstant: 40),
        ])
        springIndicatorView.start()
    }

}

Here is an example project:
SpringIndicatorBug.zip

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions