ios - 使用 AutoLayout 移动 UIView 的位置

标签 ios objective-c storyboard autolayout

我有以下代码将 UIView 的位置移动到其他位置

_completedStatusView.frame =
CGRectMake(153, _completedStatusView.frame.origin.y,
                     _completedStatusView.frame.size.width, _completedStatusView.frame.size.height);

但是,尽管当我执行 NSLog 时,它实际上移动了,但该位置并没有移动。此外,如果我禁用自动布局,它就会起作用。

最好的解决方案是什么?

最佳答案

将您的 View 前导约束连接为 IBOutlet_completedStatusViewLeading 然后执行以下操作

_completedStatusViewLeading.constant = 153.f;

关于ios - 使用 AutoLayout 移动 UIView 的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33731328/

相关文章:

ios - 订购一组对象?

android - 像 iOS subview 一样创建 Android subview

iphone - NSInternalInconsistencyException 未捕获的异常 'NSInternalInconsistencyException',原因 : 'Could not load NIB in bundle: NSBundle with name

ios - 在多个 Storyboard 中使用相同的 UIViewController

ios - 在 Storyboard 中向从 nib 加载的自定义类 UIViewController 添加 subview

ios - EXC_BAD_INSTRUCTION 在 dispatch_get_current_queue()

ios - 如何在导航 Controller 中将数据从一个 View 传递到另一个 View

ios - 调用 `errno` 后测试 `strtol` 返回 "No such process"

iphone - iOS:使用 UIBezierPath 屏蔽 UIImage

ios - 自定义 iOS 框架文件中捆绑的 Storyboard