使用 AutoLayout 移动 UIView 的位置
Move position of UIView with AutoLayout
我有以下代码将 UIView
的位置移动到其他位置
_completedStatusView.frame =
CGRectMake(153, _completedStatusView.frame.origin.y,
_completedStatusView.frame.size.width, _completedStatusView.frame.size.height);
然而,位置并没有移动,尽管当我NSLog
,它实际上移动了。此外,如果我禁用 AutoLayout.
它会起作用
最好的解决方案是什么?
将您的视图前导约束连接为 IBOutlet
说 _completedStatusViewLeading
然后执行以下操作
_completedStatusViewLeading.constant = 153.f;
我有以下代码将 UIView
的位置移动到其他位置
_completedStatusView.frame =
CGRectMake(153, _completedStatusView.frame.origin.y,
_completedStatusView.frame.size.width, _completedStatusView.frame.size.height);
然而,位置并没有移动,尽管当我NSLog
,它实际上移动了。此外,如果我禁用 AutoLayout.
最好的解决方案是什么?
将您的视图前导约束连接为 IBOutlet
说 _completedStatusViewLeading
然后执行以下操作
_completedStatusViewLeading.constant = 153.f;