How to animate view with constraint?



How to animate view with constraint?..

Answer / Chhavi Sharma

To animate a view with constraints in iOS, you can use UIView's `animateWithDuration:` method along with setting the constraints and calling `layoutIfNeeded`. Here's an example:nn```swiftn// Set initial constraintsnNSLayoutConstraint.activate([view.leadingAnchor.constraint(equalTo: superview.leadingAnchor), view.trailingAnchor.constraint(equalTo: superview.trailingAnchor)])nn// Create animation blocknUIView.animate(withDuration: 1.0, animations: {n view.leadingAnchor.constraint(equalTo: superview.leadingAnchor, constant: 100).isActive = truen})

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Apple iOS Interview Questions

What manual memory management ? How it work?

1 Answers  


What are lifecycle events of uiviewcontroller?

1 Answers  


What are the location services?

1 Answers  


What devices will support ios 7?

1 Answers  


How to change the content of your app in order to change the views displayed in the corresponding window?

1 Answers  


What are ibeacons in ios? : IOS Architect

1 Answers  


What is difference between unit tests and ui test in xcode?

1 Answers  


Explain the difference between nil and nil?

1 Answers  


What is atomic and non atomic in ios?

1 Answers  


Difference between sax parser and dom parser ?

1 Answers  


Explain Inapp purchase in iOS

1 Answers  


What is suspended state in ios?

1 Answers  


Categories