Animating/Moving views under usage of Autolayout

前端 未结 2 1509
清酒与你
清酒与你 2020-12-01 12:30

I want to move a view from one postion to another, I can implement it using

self.view.center = CGPointMake(100, 200);

however, if the proj

2条回答
  •  感动是毒
    2020-12-01 13:10

    You must change the constraints if you are using autoLayout. The way that is suggested is to make an outlet in your view controller of the constraint, then you change the constant of the constraint. If you have the time i would definitely recommend going here and watching "Auto Layout by Example" or "Best Practices for Mastering Auto Layout". They helped me out a lot. I guess the point to take away is that with autoLayout, you no longer think in terms of frames. So setting the center just doesnt work with auto layout. It's all about how views are related to each other.

提交回复
热议问题